Hi,
Dhananjay Makwana once wrote:
> I am writing a client to a web service that is running over HTTPS/SSL and
> is
> using self-signed certificate. I am using axis2 version 1.0 and am getting
> "sun.security.provider.certpath.SunCertPathBuilderException: unable to
> find
> valid certification path to requested target". The complete stack trace is
> below.

I have the exact problem, and it can be done in axis, but didn't try in axis2:

1- Define IgnoringJSEESocketFactory class:
------------------------------
public class IgnoringJSEESocketFactory extends JSSESocketFactory {

public IgnoringJSEESocketFactory(Hashtable attributes) {
super(attributes);
}

@Override
protected void initFactory() throws IOException {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted( java.security.cert.X509Certificate[] certs, 
String authType) {
}
public void checkServerTrusted( java.security.cert.X509Certificate[] certs, 
String authType) {
}
}
};

try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
sslFactory = sc.getSocketFactory();
} catch (Exception e) {
}
}

}
------------------------------

2- At the beginning of your main method:

//to statically initialize the factory, as calling its only method will cache 
the factory
new SocketFactoryFactory() {};

//override the default factory

AxisProperties.setClassDefault(SecureSocketFactory.class, 
test.IgnoringJSEESocketFactory.class.getName() );

Hope you find this useful, many thanks.


 
____________________________________________________________________________________
Sponsored Link

Mortgage rates near 39yr lows. 
$510k for $1,698/mo. Calculate new payment! 
www.LowerMyBills.com/lre

Reply via email to