Eritrea Finance

Oct 26 2017

SSL Certificate Verification: ndshakeException – Stack Overflow #magento #ssl #certificate


#

I am trying to call a HTTPS REST API through Jersey Client. And on the course of development i stumble upon following error :

So I goggled it out for a bit and found tons of solution for it. which actually works.

They are in different domain but they have a common solution to work it out.

Scenario

I am currently using a self created self-signed certificate in development environment. And hence it is bound to show up the issue.

Question

The above mentioned solution focus on skipping / allowing all certificates to be verified.

But when i move it to the production environment. then i have access to Valid Signed Certificate from trustworthy source.

  1. So are these solution any help when i move to production?
  2. Is it OK to skip SSL verification ?
  3. What are the other alternate way to achieve a common solution for both development and production environment?

The solution i used was ,

which i then in-cooperate with Jersey to make it work. And it is working great.

So. the Question again. Is this solution viable to be used in Production environment?

I am currently using a self created self-signed certificate in development environment. javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching dev.ppc.lftechnology.com found

It appears the self signed certificate is incorrect.

Below is the OpenSSL CONF file I use to create self signed certificates and certificate requests to use during testing. Save it as example-com.conf. Change the DNS names under [ alternate_names ] to suit your tastes. You can even put localhost. localhost.localdomain and 127.0.0.1 in there for testing.

If you want to create a self signed certificate, then use:

If you want to create a signing request (CSR) that will be signed by a trusted authority, then use:

The difference between a self signed certificate and a signing request is the -x509 option. With -x509 present, a self signed certificate is created. The absence of -x509 means a request is created.

If you want to print your self signed certificate or request to see what’s actually in it, then use:

If you want to test the server, then use s_client :

The above command should finish with a message similar to Verify OK (0). If you don’t receive Verify OK (0). then fix your test rig. Once OpenSSL completes successfully, then that becomes your baseline.

Is it OK to skip SSL verification ?

No. That’s very irresponsible. If you are not going to use PKIX correctly, then why use it at all?

Its better to load your self signed certificate in a Keystore (or load your private CA), and then pass it to SSLContext.init. Then everything works as intended, and there’s no need to trust everything or return true from verify .

Bruno and EJP have plenty of answers covering that subject.

What are the other alternate way to achieve a common solution for both development and production environment?

Use a well formed certificate that chains back to a trusted root.

For testing, you can create a self signed certificate. Or, create a certificate request and have it signed by your internal CA in a private PKI. In this case, you need to trust your self signed certificate or trust your internal CA.

For production, you can use a certificate signed by one of the members of the CA Zoo so others outside the organization trusts it too. StartCom and CACert offer free Class 1 certificates.

Class 1 certificates are usually domain validated and don’t allow wild cards. While the Class 1 is issued for free, they charge for revocation because that’s where the cost lies.

If you need a wild card, then you will usually to purchase a Class 2 or higher.

Is it OK to skip SSL verification? No. That’s very irresponsible.

However, in some cases you may not control the server in question to be able to install a valid certificate. If the server belongs to someone else, and you trust that server, a better solution is to use a “white list” to validate certificates only for trusted servers, otherwise use normal validation.

And install it once:

If you’re going to disable a security check, don’t do it globally.

There is a label software bug with the Java Keytool for Java version 1.7.0_60-b19, when creating a self signed certificate. See these instructions for a reference.

When it prompts you for “What is your first and last name?”, instead of typing your name, you should enter the common name, or (fully qualified domain name of your server).

You can verify if the “CN” (common name) attribute gets set correctly by calling this:

Find Java version:


Written by admin


Leave a Reply

Your email address will not be published. Required fields are marked *