Example of HTTPS with basic auth using Java generated client library

1,421 views
Skip to first unread message

Mark Spielman

unread,
Apr 1, 2016, 3:57:50 PM4/1/16
to Swagger
Is there an example around of how to use the Java Client generated library to connect with a server over HTTPS still using basic authentication.

I tried simply updating the protocol in my base bath to HTTPS but ended with the following exception:

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
at io.swagger.client.ApiClient.getAPIResponse(ApiClient.java:563)
at io.swagger.client.ApiClient.invokeAPI(ApiClient.java:593)

Thanks
Mark

wing328

unread,
Apr 2, 2016, 10:53:55 PM4/2/16
to Swagger
Please open a ticket via https://github.com/swagger-api/swagger-codegen/issues and we'll look into that.

(from the exception message, it looks like the server has a invalid cert)

Mark Spielman於 2016年4月2日星期六 UTC+8上午3時57分50秒寫道:

Mark Spielman

unread,
Apr 4, 2016, 9:48:25 AM4/4/16
to Swagger
Thank you for the pointer. That was very helpful.  

I am in a test environment and I have investigated further and confirmed that my server is using a self-signed cert. So based on your thoughts, this is likely the root cause of the exception I'm guessing. 

Does anyone have an example of how I can update the ApiClient to accept self signed certificates to allow this to work in my test environment?  I'm guessing I have to explicitly set the http client?

Thanks
Mark

Mark Spielman

unread,
Apr 4, 2016, 11:13:50 AM4/4/16
to Swagger
I have confirmed that is I update the Jersey Client to accept self-signed certificates it works without issue. So thank you for your help.

I used the following as guidance for how to accept self-signed certs.


Cheers,
Mark

William Cheng

unread,
Apr 4, 2016, 11:35:55 AM4/4/16
to swagger-sw...@googlegroups.com
Glad to hear that you've the issue resolved.

--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/JSdXHJ2VOqs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wing328

unread,
Apr 5, 2016, 7:42:08 AM4/5/16
to Swagger
To unsubscribe from this group and all its topics, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages