jcledera / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

SSL Exception / javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated #107

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Secure Connect (SSL) to webdav server using Sardine and them to LDAP server 
using SSL. HttpClient know workaround.

What is the expected output? What do you see instead?
Correct LDAP response not Exception.

What version of the product are you using?
Sardine-304, Sardine-146, Jdk-7

On what operating system?
Windows Vista

What webdav server are you hitting?
Any

What is in the server error logs?

Please provide any additional information below (including code examples
and full stack traces with line numbers in them).

SECURE LDAP CONNECTION EXAMPLE:

public static String testSecureUrl(String wduser, String wdpassword, String 
wdurl, String jksFile) {
    String  error = null;

    ///Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    System.setProperty("javax.net.ssl.trustStore", jksFile); 

    Hashtable<String,Object> env2 = new Hashtable<String,Object>();
    env2.put(Context.INITIAL_CONTEXT_FACTORY, factory); 
    env2.put(Context.PROVIDER_URL, wdurl);
    env2.put(Context.SECURITY_PRINCIPAL, wduser);   
    env2.put(Context.SECURITY_CREDENTIALS, wdpassword);
    env2.put(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);

    env2.put(Context.SECURITY_PROTOCOL, "ssl");

    try {
        DirContext ctx2 = new InitialDirContext(env2);
        error = "";
    } catch (NamingException ne) {
        //ne.printStackTrace(System.err);
        error = ne.toString();
    }       

    return error;
}

SOLUTION:

http://theskeleton.wordpress.com/2010/07/24/avoiding-the-javax-net-ssl-sslpeerun
verifiedexception-peer-not-authenticated-with-httpclient/

http://javaskeleton.blogspot.com/2010/07/avoiding-peer-not-authenticated-with.ht
ml

Original issue reported on code.google.com by hector...@gmail.com on 7 Oct 2011 at 11:38

GoogleCodeExporter commented 9 years ago
The API allows to pass your own configured instance of HTTP client with a 
custom trust manager if needed.

Original comment by dkocher@sudo.ch on 7 Oct 2011 at 2:58