Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've set up SSL on my webserver, now I need two files:

  • a certificate
  • a certificate Key

How do I create a self-signed certificate for testing purposes?

share|improve this question

1 Answer

up vote 11 down vote accepted

Ubuntu, even the 'minimal' flavour, comes with the ssl-cert package pre-installed, which means you don't need to do anything.

The files you're looking for are already on your system:

/etc/ssl/certs/ssl-cert-snakeoil.pem
/etc/ssl/private/ssl-cert-snakeoil.key


Advanced:

If for some reason you need to create a fresh certificate, you can run

sudo make-ssl-cert generate-default-snakeoil --force-overwrite 

If you want to change the expiration date of you certificate, you can manipulate the make-ssl-cert script at /usr/sbin/make-ssl-cert. Around like 124 there's a line similar to this:

openssl req -config $TMPFILE -new -x509 -nodes \ 

Where you can change the expiration date by adding the -days argument:

openssl req -config $TMPFILE -new -days 365 -x509 -nodes \ 

More options can be found in the manual page of req.

share|improve this answer
1  
ubuntu-server 12.04 ( AMI cloud image) doesn't have ssl-cert installed by default have it. But once ssl-cert is installed - /etc/ssl/certs/ssl-cert-snakeoil.pem becomes available automatically. – Stann May 3 '12 at 21:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.