How can I convert .csr into .pem file format as I have to submit csr in pem format - private-key

I have to submit CSR in pem format.
I have generated CSR using OpenSSL but got stuck in converting it into PEM format.
I have to obtain example - csr.pem from example.csr. How it can be done?

OpenSSL creates CSRs in PEM format by default.
If you generated the CSR without the -outform option, the CSR will already be in PEM format.
If you did use the -outform DER option, you can convert with:
openssl req -inform DER -in <original CSR file> -out <converted CSR file>
The .pem file extension is just a name. If the file is in PEM format, simply change the extension on the file from .csr to .pem.

Related

Get my private key

I've just recieved a certificate from Commodo. The ZIP file contains a xxx.crt and xxx.pb7b
I need to convert the xxx.pb7b file in to a xxx.pfx so that I can import it in IIS. I'm using OpenSSL for the conversion, but I need a private.KEY file.
Is there away to get\extract this file??
Export the current certificate (PFX) that is about to expire. This file contains your certificate and public key. Then use OpenSSL to extract the private key from the PFX file.
openssl pkcs12 -in myfile.pfx -nocerts -out private_key.pem -nodes

How to decrypt a RSA encrypted .txt using a public key .pub file?

I was given an RSA encrypted .txt file to be decrypted and another .pub file to be used as a key to decrypt the same. I'm new to OpenSSL.
the FILES: https://www.dropbox.com/sh/j8581rdazdy0fxs/AABqsREMVMtDK53gtHQNYfkKa?dl=0
OpenSSL> rsa -noout -text -inform PEM -in key_5.pub -pubin
I executed the following command and got a hexdump of the key_5.pub file. (As attached)
The Modulus value is in hexadecimal form. How do I recover it in decimal form?
Or is there any other way to decrypt the orignal file?

Unix encrypt file using public .asc key

I have a file I need to encrypt with a public key I got public.asc. This key was shared with me over encrypted email. I have a zip file that I need to encrypt using this public key and share over SFTP.
I tried using openssl:
openssl rsautl -encrypt -inkey public.asc -pubin -in file.zip -out file.zip.enc
but openssl displays the flag options and no error message. Also, I'm suspecting that .asc files should be encrypted with some other software.
Thanks

Generate SignedData with Openssl console (with CRT)

I'm really new to openssl and I need to generate a CMS Signed Data Message,I was given a xml file with some data in it, and I have a CRT and my private key.
How do I generate the CMS Signed Data using the xml, crt and key?? How do I write the command in the console
I've been looking in the documentation but I'm lost.
openssl cms -sign -in data.xml -nodetach -inkey private.key -signer cert.crt -out result.cms -outform PEM

How to decrypt smime.p7m file in DER format using OpenSSL in C code.

I am trying to decrypt emails using openssl.
I am getting smime.p7m file from the server. But it is in DER format.
I can decrypt this file using command prompt, with the command
openssl smime -decrypt -in openssl_working_smime.p7m -inform DER -inkey mycert.pem > dec_mail.eml
But now I want to do this using C code.
Right now I am trying to do using -
SMIME_read_PKCS7()
But this returns null with
SMIME_read_ASN1:no content type:asn_mime.c:451:
error
Any ideas how to do it?

Resources