Jetty using SSL connection in embedded development, SSL certificate generation

Source: Internet
Author: User
Tags error code pkcs12 ssl certificate ssl connection

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.