The latest projects use jetty embedded development, but need to use SSL connection, through 2 hours of effort to build an SSL environment. Includes the generation of certificates.
1: Generate service-side KeyStore Keytool-genkey-alias cheetah-keyalg rsa-keystore e:/cheetah-gateway-web/webroot/ssl/ Cheetah.keystore-validity 365
2: Generate the client certificate P12
Keytool-genkey-v-alias cheetah-keyalg rsa-storetype pkcs12-keystore e:\ssl\cheetah.p12
3: Generate CER based on client certificate P12
Keytool-export-alias cheetah-keystore e:\ssl\cheetah.p12-storetype pkcs12-storepass cheetah-rfc-file E:\ssl\cheetah . cer
4: Client certificate Import KeyStore
Keytool-import-v-file E:\ssl\cheetah.cer-keystore E:/cheetah-gateway-web/webroot/ssl/cheetah.keystore
5: View the certificate in KeyStore CER
Keytool-list-keystore E:/cheetah-gateway-web/webroot/ssl/cheetah.keystore
6: Service-side KeyStore export CER
Keytool-keystore E:/cheetah-gateway-web/webroot/ssl/cheetah.keystore-export-alias Cheetah-file E:\ssl\server.cer
7: Certificate imported to JDK default KeyStore
Keytool-import-trustcacerts-alias cheetah-file E:\ssl\server.cer-keystore "%java_home%/jre/lib/security/cacerts"- Storepass Changeit
8: Remove the certificate from KeyStore
Keytool-delete-alias cheetah-keystore "%java_home%/jre/lib/security/cacerts"-storepass Changeit
Follow steps 1 and 4 above to generate the certificate, and start the SSL connection by following the code below
Sslsocketconnector ssl_connector = new Sslsocketconnector ();
Ssl_connector.setport (8090);
Sslcontextfactory CF = Ssl_connector.getsslcontextfactory ();
Cf.setkeystorepath ("Webroot/ssl/cheetah.keystore");
Cf.setkeystorepassword ("Cheetah");
Cf.setkeymanagerpassword ("Cheetah");
_server.addconnector (Ssl_connector);
If there is an error code:ssl_error_weak_server_ephemeral_dh_key in Firefox then it will not open.
If you need to change it, go inside the about:config and change the following two values from true to False Security.ssl3.dhe_rsa_aes_128_sha=false security.ssl3.dhe_rsa_aes_256_ Sha=false