Which file format is recognized for a public cryptographic key?

I have a server certificate (certificate.crt) Caja is able to show; I just need to right click on the file and select Open with View file. I have also a private key (private_key.pem) which Caja is able to show.

I create the public key from that private key with openssl rsa -in private_key.pem -pubout -out public_key.pem. When I open that file using the same method, I do not get any detail about the public key. I rather get this message in the dialog box that appears:

public_key.pem

Could not display “public_key.pem”
Reason: Cannot display a file of this type.

Caja shows a different icon for the public_key.pem file. I thought that meant the file was recognized.

screenshot

I tried changed the extension from .pem to .key. The icon changes, but Caja offers to open the file with Engrampa Archive Manager, which does not recognize the file format.

screenshot

Which format should I use to save a RSA public key?

This is from the ArchWiki:

SSH keys are always generated in pairs with one known as the private key and the other as the public key. The private key is known only to you and it should be safely guarded. By contrast, the public key can be shared freely with any SSH server to which you wish to connect.

Here’s how to create a key-pair

Hope this helps a little. :wink:

The problem is not how the public key is generated. A RSA private key contains the public key information too, so openssl rsa -in private_key.pem -pubout -out public_key.pem effectively stores the public key in the public_key.pem file.
The problem is that, opening that .pem file, the application that opens .pem files shows the warning I quoted.

If I create a key-pair with ssh-keygen and I try to open the public key with Caja, Caja thinks it is a Microsoft Publisher document and tells me there are not applications to open that type of file.

(I guess it is just a matter of finding the right file type.)

Not sure I understand you correctly, so forgive me if not.

Why would you want to open the keyfile in a filemanager (caja)?
Just renaming a file’s ending (like you said, from .pem to .key) does absolutely nothing to the file-content or -container itself.

The original file-format for an openssl-created keyfile (.pem) is base64. Maybe, some editors can view it, but I can’t say for sure.

There are some tools in the AUR like this one:

To view the contents of a .pem-file

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner:
https://aur.archlinux.org/packages/keystore-explorer

To answer my question: Out of the box, MATE is not able to parse the public key data contained in a PEM file, nor any other file type.

screenshot

In Properties Caja recognize the file type correctly, though.

screenshot

I also tried to convert the public key file from PEM to XML <RSAKeyValue>, but that did not work either.

I did not find any application that would register itself for .pem files or other files used for public/private keys.

As a side note, it seems the file type is not determined only by the file extension, since the type shown for the private.pem file is X.509 Certificate (application/x-x509-ca-cert).

screenshot

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.