https - Getting java.security.cert.CertificateException, however the certificate is imported into the truststore -


i receive a

java.security.cert.certificateexception: no subject alternative names present 

exception, i've imported certificate trusrstore. here setup:

i'm using small https server based on com.sun.net.httpserver.httpsserver. i've create keystore self signed certificate:

keytool -genkey -keyalg rsa -alias mycert -keystore keystore.jks -storepass mypass -validity 360 -keysize 2048  

i'm passing path , password keystore vm arguments djavax.net.ssl.keystore=/tmp/truststore.jks djavax.net.ssl.keystorepassword=mypass

if run openssl s_client -connect 192.168.1.101:4443 can see uses right certificate.

to trust certificate on client site, i've exported certificate server keystore , imported client truststore:

  keytool -export -alias mycert -file mycert.crt -keystore keystore.jks   keytool -import -trustcacerts -alias -file mycert.crt -keystore truststore.jks 

for client use small test program using jersey. i'm passing path truststore vm argument -djavax.net.ssl.truststore=/tmp/truststore.jks

public class tester {     public static void main(string[] args) {          client client = clientbuilder.newclient();         try {             string name = client.target("https://192.168.1.101:4443")                     .request(mediatype.text_plain)                     .get(string.class);              system.out.println(name);         } catch (final exception e) {             system.err.println(e);         }     } } 

but self signed certificate in truststore, the

  java.security.cert.certificateexception: no subject alternative names present exception 

what can reason it?

the https certificate should contain subjectaltname extension value should ip address (192.168.1.101 in case) or dns name of host.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -