use of javax.net.ssl.SSLPeerUnverifiedException in project XobotOS by xamarin.
the class OpenSSLSessionImpl method createPeerCertificateChain.
/**
* Provide a value to initialize the volatile peerCertificateChain
* field based on the native SSL_SESSION
*/
private javax.security.cert.X509Certificate[] createPeerCertificateChain() throws SSLPeerUnverifiedException {
try {
javax.security.cert.X509Certificate[] chain = new javax.security.cert.X509Certificate[peerCertificates.length];
for (int i = 0; i < peerCertificates.length; i++) {
byte[] encoded = peerCertificates[i].getEncoded();
chain[i] = javax.security.cert.X509Certificate.getInstance(encoded);
}
return chain;
} catch (CertificateEncodingException e) {
SSLPeerUnverifiedException exception = new SSLPeerUnverifiedException(e.getMessage());
exception.initCause(exception);
throw exception;
} catch (CertificateException e) {
SSLPeerUnverifiedException exception = new SSLPeerUnverifiedException(e.getMessage());
exception.initCause(exception);
throw exception;
}
}
use of javax.net.ssl.SSLPeerUnverifiedException in project Asqatasun by Asqatasun.
the class DownloaderImpl method download.
private String download(String url) {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
httpclient.getParams().setParameter("http.socket.timeout", Integer.valueOf(10000));
httpclient.getParams().setParameter("http.connection.timeout", Integer.valueOf(10000));
// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody;
try {
responseBody = httpclient.execute(httpget, responseHandler);
} catch (HttpResponseException ex) {
LOGGER.warn(ex.getMessage() + " " + url);
return "";
} catch (UnknownHostException ex) {
LOGGER.warn(ex.getMessage() + " " + url);
return "";
} catch (SSLPeerUnverifiedException ex) {
LOGGER.warn(ex.getMessage() + " " + url);
return "";
} catch (IOException ex) {
LOGGER.warn(ex.getMessage() + " " + url);
return "";
}
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
return responseBody;
}
use of javax.net.ssl.SSLPeerUnverifiedException in project robovm by robovm.
the class SSLSocketTest method test_SSLSocket_startHandshake.
public void test_SSLSocket_startHandshake() throws Exception {
final TestSSLContext c = TestSSLContext.create();
SSLSocket client = (SSLSocket) c.clientContext.getSocketFactory().createSocket(c.host, c.port);
final SSLSocket server = (SSLSocket) c.serverSocket.accept();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Void> future = executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
server.startHandshake();
assertNotNull(server.getSession());
try {
server.getSession().getPeerCertificates();
fail();
} catch (SSLPeerUnverifiedException expected) {
}
Certificate[] localCertificates = server.getSession().getLocalCertificates();
assertNotNull(localCertificates);
TestKeyStore.assertChainLength(localCertificates);
assertNotNull(localCertificates[0]);
TestSSLContext.assertServerCertificateChain(c.serverTrustManager, localCertificates);
TestSSLContext.assertCertificateInKeyStore(localCertificates[0], c.serverKeyStore);
return null;
}
});
executor.shutdown();
client.startHandshake();
assertNotNull(client.getSession());
assertNull(client.getSession().getLocalCertificates());
Certificate[] peerCertificates = client.getSession().getPeerCertificates();
assertNotNull(peerCertificates);
TestKeyStore.assertChainLength(peerCertificates);
assertNotNull(peerCertificates[0]);
TestSSLContext.assertServerCertificateChain(c.clientTrustManager, peerCertificates);
TestSSLContext.assertCertificateInKeyStore(peerCertificates[0], c.serverKeyStore);
future.get();
client.close();
server.close();
c.close();
}
use of javax.net.ssl.SSLPeerUnverifiedException in project robovm by robovm.
the class SSLPeerUnverifiedExceptionTest method test_Constructor01.
/**
* Test for <code>SSLPeerUnverifiedException(String)</code> constructor Assertion:
* constructs SSLPeerUnverifiedException with detail message msg. Parameter
* <code>msg</code> is not null.
*/
public void test_Constructor01() {
SSLPeerUnverifiedException sslE;
for (int i = 0; i < msgs.length; i++) {
sslE = new SSLPeerUnverifiedException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), sslE.getMessage(), msgs[i]);
assertNull("getCause() must return null", sslE.getCause());
}
}
use of javax.net.ssl.SSLPeerUnverifiedException in project robovm by robovm.
the class OpenSSLSessionImpl method createPeerCertificateChain.
/**
* Provide a value to initialize the volatile peerCertificateChain
* field based on the native SSL_SESSION
*/
private javax.security.cert.X509Certificate[] createPeerCertificateChain() throws SSLPeerUnverifiedException {
try {
javax.security.cert.X509Certificate[] chain = new javax.security.cert.X509Certificate[peerCertificates.length];
for (int i = 0; i < peerCertificates.length; i++) {
byte[] encoded = peerCertificates[i].getEncoded();
chain[i] = javax.security.cert.X509Certificate.getInstance(encoded);
}
return chain;
} catch (CertificateEncodingException e) {
SSLPeerUnverifiedException exception = new SSLPeerUnverifiedException(e.getMessage());
exception.initCause(exception);
throw exception;
} catch (CertificateException e) {
SSLPeerUnverifiedException exception = new SSLPeerUnverifiedException(e.getMessage());
exception.initCause(exception);
throw exception;
}
}
Aggregations