Fix TLSUtils.AcceptAllTrustManager

Should not throw an Exception, but instead return a zero-sized
array. Also add some javadoc.
This commit is contained in:
Florian Schmaus 2014-07-09 09:42:31 +02:00
parent bdf9a75c4f
commit b0825f73fd
1 changed files with 11 additions and 2 deletions

View File

@ -78,7 +78,8 @@ public class TLSUtils {
/**
* Accept all SSL/TLS certificates.
* <p>
* <b>Warning</b> Use with care. Only use this method if you understand the implications.
* <b>Warning</b> Use with care. This method make the Connection use
* {@link AcceptAllTrustManager}. Only use this method if you understand the implications.
* </p>
*
* @param conf
@ -134,6 +135,14 @@ public class TLSUtils {
}
}
/**
* A {@link X509TrustManager} that <b>doesn't validate</b> X.509 certificates.
* <p>
* Connections that use this TrustManager will just be encrypted, without any guarantee that the
* counter part is actually the intended one. Man-in-the-Middle attacks will be possible, since
* any certificate presented by the attacker will be considered valid.
* </p>
*/
public static class AcceptAllTrustManager implements X509TrustManager {
@Override
@ -150,7 +159,7 @@ public class TLSUtils {
@Override
public X509Certificate[] getAcceptedIssuers() {
throw new UnsupportedOperationException();
return new X509Certificate[0];
}
}
}