Got a 'How do I' question? Join our live 'Ask a Trainer' session happening now for instant help and pro tips!

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

SOLVED
Go to solution
AndrewG712
Campaign Expert
0 Votes

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
AndrewG712
Campaign Expert
0 Votes

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
AndrewG712
Campaign Expert
0 Votes

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.

Shannon_W
Employee
0 Votes

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

Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up