Monday 16 May 2011

Creating a certificate in openssl


Get the binary distribution of openssl from http://www.slproweb.com/products/Win32OpenSSL.html

Install "Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) " first from http://www.microsoft.com/downloads/en/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en


Add openssl bin directory to the path environment variable

# In a comand prompt create a CA folder
mkdir CA
cd CA

# Create expected folders and files
mkdir private
mkdir newcerts
mkdir certs
mkdir crl

touch index.txt
touch serial # Best to copy this file from the demoCA in the bin directory

# change dir in openssl.cfg from ./demoCA to .

openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days 365
openssl req -nodes -new -x509 -keyout newreq.pem -out newreq.pem -days 365
openssl x509 -x509toreq -in newreq.pem -signkey newreq.pem -out tmp.pem
openssl ca -policy policy_anything -out newcert.pem -infiles tmp.pem
openssl x509 -inform PEM -in newcert.pem -outform DER -out newcert.cer

No comments: