How to create X509 certificates for testing

This page provides a few methods to create X509 certificates for testing purposes.

Using OpenSSL

For this you need to have OpenSSL installed. On Windows, convenient installers are available at or

Self-signed certificates

Many tutorials exist on the web, such as these:

The easiest solution I've found so far is that one-line example:

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout test.pem -out test.pem

Or if you prefer to have separate files for the private key and the certificate:

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout test.key -out test.cert


Certificates with a CA

Other options



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

win openssl-warning-cant-open-config-file-usrlocalsslopensslcnf

On windows, to prevent error message concerning openssl.cnf :
You should fix env var :

for exemple...

Ref :