Using Openssl To Create Keys For Mac

  1. Using Openssl To Create Keys For Mac Catalina
  2. Openssl Create Key Pair
  3. Openssl Create Key File
If you want to do a quick command-line generation of a HMAC, then the openssl command is useful.

Next, you'll create a server certificate using OpenSSL. Create the certificate's key. Use the following command to generate the key for the server certificate. Openssl ecparam -out fabrikam.key -name prime256v1 -genkey Create the CSR (Certificate Signing Request) The CSR is a public key that is given to a CA when requesting a certificate.

  1. The first step to obtaining an SSL certificate is using OpenSSL to create a certificate signing request (CSR) that can be sent to a Certificate Authority (CA) (e.g., DigiCert). The CSR contains the common name (s) you want your certificate to secure, information about your company, and your public key.
  2. The last step in the process is to sign the request using a private key. In this example we are signing the certificate request with the same key that was used to create it. That's why it earns the name 'self-signed'. # Sign the certificate signing request openssl x509 -req -days 365 -in signreq.csr -signkey privkey.pem -out certificate.pem.
  3. Step 3: Creating the CA Certificate and Private Key. Now, it is time to generate a pair of keys (public and private). The public will be issued in a digital certificate signed by the private key, hence, self-signed. # cd /root/ca # openssl req -config openssl.cnf -new -x509 -days 1825 -extensions v3ca -keyout private/ca.key -out certs/ca.crt.
For example:
...or alternatively...
Reference:
http://stackoverflow.com/questions/7285059/hmac-sha1-in-bash

BUT, note in the above commands, the 'value' and 'key' are ascii strings.The above syntax is problematic if you want to specify a Binary value for the key,which does not correspond to printable characters.

This had been a problem reported in the past:
http://www.mail-archive.com/openssl-users@openssl.org/msg49098.html
http://www.mail-archive.com/openssl-users@openssl.org/msg49100.html

Key

But I can report here, that certainly with openssl v1.0.0, the following method allows you to specify a binary key, by passing it as a string of hex values.

To demonstate the point, let's get the hex string equivalent of the three character acsii string 'key',so that we can use the same hashes as in the examples above.To do this, I use utility 'xxd' which does a hexdump.(For further information on 'xdd' see my previousblog posts.)
Ok, so the hex-string '6b6579' corresponds to ascii string 'key'.

So after reading up the man page for 'openssl dgst', we try a further alternate formof the command, like this:
Note the use of the '-macopt hexkey:string' option which allows you to specify the keyin hexadecimal (two hex digits per byte).

Nice! So now we can do something like this:
I hope to show a practical use of the above in a future blog post!

Finally, I will just confirm some details of the system that gave the above output:
By the way, if your wondering about the '(stdin)= ' that openssl is outputing, then see my previous blog post on this subject.

If you want to convert your website from HTTP to HTTPS, you need to get a SSL certificate from a valid organization like Verisign or Thawte. You can also generate self signed SSL certificate for testing purpose.

In this article, let us review how to generate private key file (server.key), certificate signing request file (server.csr) and webserver certificate file (server.crt) that can be used on Apache server with mod_ssl.

Using Openssl To Create Keys For Mac Catalina

Key, CSR and CRT File Naming Convention

I typically like to name the files with the domain name of the HTTPS URL that will be using this certificate. This makes it easier to identify and maintain.

  • Instead of server.key, I use www.thegeekstuff.com.key
  • Instead of server.csr, I use www.thegeekstuff.com.csr
  • Instead of server.crt, I use www.thegeekstuff.com.crt

1. Generate Private Key on the Server Running Apache + mod_ssl

First, generate a private key on the Linux server that runs Apache webserver using openssl command as shown below.

The generated private key looks like the following.

2. Generate a Certificate Signing Request (CSR)

Using the key generate above, you should generate a certificate request file (csr) using openssl as shown below.

3. Generate a Self-Signed SSL Certificate

For testing purpose, you can generate a self-signed SSL certificate that is valid for 1 year using openssl command as shown below.


You can use this method to generate Apache SSL Key, CSR and CRT file in most of the Linux, Unix systems including Ubuntu, Debian, CentOS, Fedora and Red Hat.

4. Get a Valid Trial SSL Certificate (Optional)

Instead of signing it youself, you can also generate a valid trial SSL certificate from thawte. i.e Before spending the money on purchasing a certificate, you can also get a valid fully functional 21 day trial SSL certificates from Thawte. Once this valid certificate works, you can either decide to purchase it from Thawte or any other SSL signing organization.

This step is optional and not really required. For testing purpose, you can always use the self-signed certificate that was generated from the above step.

Go to Thwate trial certificate request page and do the following:

  • Select “SSL Web Server Certificate (All servers)” under the “select your trial certificate”.
  • Do not check the PKCS #7 check-box under the “configure certificate”
  • Copy/Paste the *.csr file that you generate above in the textbox under “certificate signing request (CSR)”
  • Click on next at the bottom, which will give you a 21-day free trial certificate.


Copy/Paste the trial certificate to the www.thegeekstuff.com.crt file as shown below.

> Add your comment

Openssl Create Key Pair

If you enjoyed this article, you might also like..

Openssl Create Key File



Next post: Google Chrome OS – Beginning of End of Microsoft?

Previous post: Blog Makeover: New Thesis Theme In Action