title: How to generate trusted self signed certificate with SHA2 signing algorithm using keytool?
body: <p>I am trying to establish a secure connection for my application using jetty http server version 8.1.8.v20121106 with self signed certificate.</p>
  
  <p>I am generating self signed certificate with the following command,</p>
  
  <ol>
  <li><p>keytool -genkey -alias mykey -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 365 -keypass password -keystore keystore.jks -storepass password</p></li>
  <li><p>keytool -export -alias mykey -file server.cer -keystore keystore.jks -storepass password</p></li>
  <li><p>keytool -import -alias mykey -file server.cer -keystore truststore.jks -storepass password</p></li>
  </ol>
  
  <p>So, totally 3 files generate (keystore.jks,server.cer,truststore.jks)</p>
  
  <p>After the server gets started, I got the following error in my browser. <strong>There are issues with the site's certificate chain (net::ERR_CERT_AUTHORITY_INVALID).</strong></p>
  
  <p><a href="https://i.stack.imgur.com/xH0GX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xH0GX.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/rc44D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rc44D.png" alt="enter image description here"></a></p>
  
  <p>Could anyone help me to generate a trusted self signed certificate using keytool.</p>
  
  <p>Thanks in advance.</p>