Ann Kilzer
Ann Kilzer

Reputation: 1361

SSLPeerUnverifiedException in basic twilio-java app

I'm following the Twilio-java example from the github page.

Here's the code snippet I wrote:

    private boolean doSms(Notification notification) {
    String message = "test";
    try {
        final MessageFactory messageFactory = mainAccount.getMessageFactory();
        final List<NameValuePair> messageParams = new ArrayList<NameValuePair>();
        messageParams.add(new BasicNameValuePair("To", notification.getUser().getPhoneNumber())); 
        messageParams.add(new BasicNameValuePair("From", BoundaryNumber)); 
        messageParams.add(new BasicNameValuePair("Body", message));
        messageFactory.create(messageParams);
    } catch (TwilioRestException e) {
        return false;
    }
    return true;
}

I'm following the example very closely, however, it seems like I'm getting an SSLPeerUnverifiedException:

Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
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.twilio.sdk.TwilioRestClient.request(TwilioRestClient.java:416)
... 11 more

I'm using a trial account and making an SMS from my Twilio number (BoundaryNumber) to my mobile (which is registered in Twilio) Now I've done a little digging and found some similar problems. For instance, Bryan seems to be on the right track here.

I'm just not sure how to fix the certificate issue. I'm not sure where to find the twilio certs, and a lot of the command line advice doesn't really work on OS X (10.9 Mavericks). I believe certs are managed with the Keychain access tool on OS X.

Upvotes: 0

Views: 880

Answers (1)

GeT
GeT

Reputation: 550

Somehow there is a problem with Mavericks. It crashes the JDK Installation during the update. My solution was for this problem to remove and reinstall the newest version of the jdk (http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html).

Upvotes: 1

Related Questions