Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create an ECDSA certificate with the OpenSSL command-line

I'm building a server app in C++ that needs to accept a certificate containing an ECDSA public key. It must validate the certificate and, upon verification, use the public key contained in the certificate to authenticate a message sent along with the certificate.

I have all this working using ECDSA keypairs generated on the fly - i.e. my code is working nicely - but now I need to do the certificate piece.

And I figured I could use OpenSSL's command-line to create the certificate which is installed on the client (along with the ECDSA private key in a separate file).

Can anyone help?

like image 943
ShaunB Avatar asked Aug 16 '12 16:08

ShaunB


People also ask

How do I use OpenSSL to generate certificates in Windows?

Right-click the openssl.exe file and select Run as administrator. Enter the following command to begin generating a certificate and private key: req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey. key -out certificate.

How do you create an EC?

Visit the respective State's official land registration website and select the option to apply for an EC. Enter all the required fields on the application for encumbrance certificate window, then click save/update. Enter the search period for which you require the EC and then click on 'Calculate Fee'.


1 Answers

If you haven't chosen a curve, you can list them with this command:

openssl ecparam -list_curves 

I picked secp256r1 for this example. Use this to generate an EC private key if you don't have one already:

openssl ecparam -out ec_key.pem -name secp256r1 -genkey  

And then generate the certificate. Your certificate will be in cert.pem.

openssl req -new -key ec_key.pem -x509 -nodes -days 365 -out cert.pem 

See also: req, ecparam

like image 60
indiv Avatar answered Oct 22 '22 21:10

indiv