We want a new WebService to connect via HTTPS, and we want to set the server certificate for doing so. I’m trying to explain the steps I’ve been doing till now, with detail:
We created our server certificate, with this command:
keytool -storepass * -keystore .my_keystore -keypass * -genkey -alias ALIAS -dname "CN=[FQDN here], OU=ID, O=*, L=*, ST=*, C=*" -keyalg RSA -keysize 2048 -validity 3000
We generated a signing request for the certificate
keytool -storepass * -keystore .my_keystore -certreq -alias ALIAS -file ALIAS.csr
We sent the CSR to our company (which has its own CA), and got the signed certificate.
We validated the certificate:
openssl verify -CAfile CA_certificate.pem ALIAS_SIGNED.pem
ALIAS_SIGNED.pem: OK
We’ve imported this signed certificate on our keystore.
keytool -importcert -keystore .my_keystore -alias ALIAS_SIGNED -file ALIAS_SIGNED.pem -storepass *
We're trying to connect from another machine with the company’s CA certificate installed on Java’s cacerts file:
$ openssl s_client -connect [IP]:[port] CONNECTED(00000003) depth=0 /C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] verify error:num=18:self signed certificate verify return:1 depth=0 /C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] verify return:1 Certificate chain 0 s:/C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] i:/C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] Server certificate -----BEGIN CERTIFICATE----- ABcDefGHI...z -----END CERTIFICATE----- subject=/C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] issuer=/C=*/ST=*/L=*/O=*/OU=ID/CN=[FQDN here] No client certificate CA names sent SSL handshake has read 1610 bytes and written 279 bytes New, TLSv1/SSLv3, Cipher is EDH-RSA-DES-CBC3-SHA Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 Cipher : EDH-RSA-DES-CBC3-SHA Session-ID: 5790...EAB54 Session-ID-ctx: Master-Key: D07...3E13 Key-Arg : None Start Time: 1369086263 Timeout : 300 (sec) Verify return code: 18 (self signed certificate) closed
But that error is all I get. I’ve tried to install all possible certificates (CA, signed and without signing) in any possible keystore, but the openssl client doesn’t validates it.
Can you provide any hint, please?
Sorry if there is any inconsistence in here (such as mixing keytool and openssl): we are rookies on this, and after many days of struggling, haven’t reached any working solution.