The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

javax.net.ssl.SSLException: hostname in certificate didn't match

SOLVED
Go to solution
Highlighted
Occasional Advisor

javax.net.ssl.SSLException: hostname in certificate didn't match

I'm running into an odd issue.  I can get the unit tests within the Java CTCTWSJavaLib project to run.  When I incorporate the code into my own project, I get the following exception:

 

javax.net.ssl.SSLException: hostname in certificate didn't match: <api.constantcontact.com/208.75.122.62> != <api.constantcontact.com> OR <api.constantcontact.com>
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228)
at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:149)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:130)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:495)
at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:62)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.ctctlabs.ctctwsjavalib.CTCTConnection.doGetRequest(CTCTConnection.java:109)
at com.ctctlabs.ctctwsjavalib.CTCTConnection.authenticate(CTCTConnection.java:196)
at com.accuval.appraisal.server.service.constantcontact.webservice.ConstantContactWebServiceWrapper.getCampaigns(ConstantContactWebServiceWrapper.java:31)

 

I can't seem to figure out why the hostname is changing from one project to another, and why this is causing the connection to fail.

 

Has anyone else run into this issue?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Advisor

Re: javax.net.ssl.SSLException: hostname in certificate didn't match

So I found a solution to this, but not sure why it worked.  I figured it had something to do with the way my project was building the dependencies. So I changed some build path settings.

 

In Eclipse, I had to modify the Order and Export order in my project's Java Build Path panel.  I moved the CTCTWSJavaLib  project to the top of the list, and checked it's box.   This allwed the code to run correctly.  I'm not sure why this fixed the problem, as the Exception I was geeting seemd unrelated.

View solution in original post

2 REPLIES 2
Highlighted
Occasional Advisor

Re: javax.net.ssl.SSLException: hostname in certificate didn't match

So I found a solution to this, but not sure why it worked.  I figured it had something to do with the way my project was building the dependencies. So I changed some build path settings.

 

In Eclipse, I had to modify the Order and Export order in my project's Java Build Path panel.  I moved the CTCTWSJavaLib  project to the top of the list, and checked it's box.   This allwed the code to run correctly.  I'm not sure why this fixed the problem, as the Exception I was geeting seemd unrelated.

View solution in original post

Highlighted
Employee

Re: javax.net.ssl.SSLException: hostname in certificate didn't match

Hi,

 

Thank you very much for posting the solution.  The java library isn't officially supported and we don't often get questions on it, but it looks like the library has a reference to both the api url and IP address, which wasn't matching for certificate purposes (only url is needed - api.constantcontact.com).  Changing the order most likely overrode the library's other reference to ip and url.  Sorry for the trouble!

 

Best Regards,

Shannon W.

API Support Specialist

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured