mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 09:39:39 +02:00
Compatible with JDK 1.2 and 1.3.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1831 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
f5ee8e1eb1
commit
b2fa523fcb
2 changed files with 42 additions and 8 deletions
|
@ -59,6 +59,7 @@ import java.security.KeyManagementException;
|
|||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import javax.net.*;
|
||||
import com.sun.net.ssl.*;
|
||||
|
||||
/**
|
||||
* Creates an SSL connection to a XMPP (Jabber) server.
|
||||
|
@ -76,7 +77,7 @@ public class SSLXMPPConnection extends XMPPConnection {
|
|||
this.port = port;
|
||||
try {
|
||||
SSLSocketFactory sslFactory = new DummySSLSocketFactory();
|
||||
this.socket = (SSLSocket)sslFactory.createSocket(host, port);
|
||||
this.socket = sslFactory.createSocket(host, port);
|
||||
}
|
||||
catch (UnknownHostException uhe) {
|
||||
throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe);
|
||||
|
@ -155,17 +156,20 @@ public class SSLXMPPConnection extends XMPPConnection {
|
|||
*/
|
||||
private static class DummyTrustManager implements X509TrustManager {
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
|
||||
public boolean isClientTrusted(X509Certificate[] cert) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
try {
|
||||
chain[0].checkValidity();
|
||||
public boolean isServerTrusted(X509Certificate[] cert) {
|
||||
try {
|
||||
cert[0].checkValidity();
|
||||
return true;
|
||||
}
|
||||
catch (CertificateExpiredException e) {
|
||||
return false;
|
||||
}
|
||||
catch (CertificateNotYetValidException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue