3

I have the following files:

ca_bundle.crt
certificate.crt
private.key

In our Android project, we are trying to establish a handshake to a secure WebSocket and it requires a base64 .cer format certificate. Can anyone tell me how can I convert the above files to working base64 .cer file?

Thanks

Saif Ali
  • 133
  • 1
  • 1
  • 4
  • 2
    Presumably, by Base-64, you mean PEM? You can Base-64 any file with `openssl base64 -in -out `. PEM are different though and you may have them already. Have you confirmed these aren't PEM? – garethTheRed Aug 20 '20 at 13:26
  • @garethTheRed Yes we have confirmed they are not base64 pem rather they demand x.509 base 64 CER. – Saif Ali Aug 20 '20 at 13:45
  • 1
    I was asking what the format of the current (three) files are. You can only have a bundle as a PEM file (with whatever extension you wish - sometimes `.crt`) or a certificate-only PKCS#7/CMS (usually with `.p7b` or `.p7c` extension). Basically, you need to clarify what format the source are before anyone can help you convert them. – garethTheRed Aug 20 '20 at 14:52
  • 1
    Remember that the filename by itself, including the extension, is not important for computers (except in some brain-dead OS maybe). Only the content counts. You can name your files `foobar.42` and they should work as well as long as the content is right. The naming and the extensions (`crt`, `cert`, `pem`, `cer`, etc.) are just conventions. – Patrick Mevzek Aug 21 '20 at 17:20

2 Answers2

2

Can you copy the files to a windows machine? You don't need openssl to do this conversion, and it looks quite easy.

  1. (on windows machine) Double-click on the *.crt file to open it into the certificate display. If it's already imported into certmgr.msc, just browse to it and double click the cert file.
  2. Select the Details tab, then select the Copy to file option.
  3. Choose next on the Certificate Wizard.
  4. Select Base-64 encoded X.509 (.CER) in the File format window, then Next.
  5. Finally, enter the path for which to save the new file... make sure it has a .cer extension.

enter image description here

d34db33f
  • 98
  • 1
  • 8
2
openssl x509 -inform <youchoose> -in certificate.crt -outform <youchoose> -out certificate-out.youchoose

see man openssl x509 for details. You can choose from DER, PEM and NET.

I think you just want to go from DER to PEM (CER is not really an encoding, see here)

pierpaciugo
  • 106
  • 2