Add expiry to self-signed openssl certificate

Original command which you might be using for generating the certificate:

openssl x509 -req 
-in domain.com.csr 
-signkey domain.com.key 
-out domain.com.pem -extfile domain.com.ext

You need to add the -days argument to the above command following the days you want for your certificate expiry. The command will look like this:

openssl x509 -req 
-in domain.com.csr 
-signkey domain.com.key 
-out domain.com.pem -extfile domain.com.ext
-days 120

Above 120 days is the expiry time for our self-signed certificate.