Open jmewes opened 7 years ago
Here is a description of the workaround: https://myshittycode.com/2015/12/17/java-https-unable-to-find-valid-certification-path-to-requested-target-2/
With this command the certificate can be registered in the keystore:
JDK 9:
sudo keytool -import -trustcacerts -file $CRT_FILE -alias google -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit
JDK 8:
sudo keytool -import -trustcacerts -file $CRT_FILE -alias google -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit
For a Bahmni installation without a valid certificate on Digital Ocean even this workaround doesn't work out:
Caused by: com.mashape.unirest.http.exceptions.UnirestException: javax.net.ssl.SSLPeerUnverifiedException: Host name '207.154.220.133' does not match the certificate subject provided by the peer (EMAILADDRESS=root@centos-8gb-fra1-01, CN=centos-8gb-fra1-01, OU=SomeOrganizationalUnit, O=SomeOrganization, L=SomeCity, ST=SomeState, C=--)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:143)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at com.experimental.openmrs.OpenMRS.get(OpenMRS.java:40)
... 49 more
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name '207.154.220.133' does not match the certificate subject provided by the peer (EMAILADDRESS=root@centos-8gb-fra1-01, CN=centos-8gb-fra1-01, OU=SomeOrganizationalUnit, O=SomeOrganization, L=SomeCity, ST=SomeState, C=--)
The libraries used for accessing the OpenMRS API reject to connect to an API without a proper SSL certificate. A possible workaround is to download the certification and register it in the Java keystore. This is kind of complicated and might cause problems later on.