title: Specify days (expire date) for generated self-signed certificate with openssl
body: <p>I haven't found where can I ask this question, but looks like it is <a href="https://meta.stackoverflow.com/questions/342108/questions-regarding-openssl">the right place</a>.</p>
  
  <p>With following command I can generate self-signed certificate for Certification authority (CA):</p>
  
  <pre><code>$ openssl req -new -x509 -days 3650 -config ./openssl/ca.cnf -key ./dist/ca_key.pem -out ./dist/ca_cert.pem
  </code></pre>
  
  <p>You can see option <code>-days</code> that set end date. And if I check generated certificate I see that <code>days</code> option work:</p>
  
  <pre><code>$ openssl x509 -enddate -noout -in ./dist/ca_cert.pem
  notAfter=Aug 23 11:29:57 2028 GMT
  </code></pre>
  
  <p>And in all <a href="https://certificatetools.com/newui/" rel="noreferrer">places</a>/<a href="https://medium.com/@sevcsik/authentication-using-https-client-certificates-3c9d270e8326" rel="noreferrer">tutorials</a> people use <code>days</code> option too.</p>
  
  <p>However how can I specify the same option in <code>.cnf</code> config?
  I investigated a lot of <a href="http://web.mit.edu/crypto/openssl.cnf" rel="noreferrer">articles</a> but nothig seems to work (<code>ca.cnf</code>):</p>
  
  <pre><code>[ ca ]
  default_ca      = my_ca
  default_days    = 3650 # does not work
  days            = 3650 # does not work
  
  [ my_ca ]
  ...
  default_days    = 3650 # does not work
  days            = 3650 # does not work
  ...
  
  [ req ]
  ...
  default_days    = 3650 # does not work
  days            = 3650 # does not work
  ...
  </code></pre>
  
  <p>None of above works, if I do not use <code>-days</code> option:</p>
  
  <pre><code>$ openssl req -new -x509 -config ./openssl/ca.cnf -keyout ./dist/ca_key.pem -out ./dist/ca_cert.pem
  $ openssl x509 -enddate -noout -in ./dist/ca_cert.pem
  notAfter=Sep 25 11:38:48 2018 GMT
  </code></pre>
  
  <p>You can see that default 30 days had been used.</p>
  
  <p>Where in <code>.cnf</code> config I must specify <code>-days</code> option?</p>