From faec826c0d976301b075500b079241bc88619658 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 15 Oct 2003 16:41:45 +0000 Subject: Verify remote peer cert during MMTP handshake --- .../fancydress/type3/mmtp/MMTPTrustManager.java | 59 +++++++++++++++------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'src/org/noreply/fancydress/type3/mmtp/MMTPTrustManager.java') diff --git a/src/org/noreply/fancydress/type3/mmtp/MMTPTrustManager.java b/src/org/noreply/fancydress/type3/mmtp/MMTPTrustManager.java index e39f5f9..4748a84 100644 --- a/src/org/noreply/fancydress/type3/mmtp/MMTPTrustManager.java +++ b/src/org/noreply/fancydress/type3/mmtp/MMTPTrustManager.java @@ -5,13 +5,28 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import javax.net.ssl.X509TrustManager; import java.security.AlgorithmParameters; -import java.math.*; +import java.security.NoSuchAlgorithmException; +import java.security.InvalidKeyException; +import java.security.NoSuchProviderException; +import java.security.SignatureException; +import java.math.BigInteger; import org.bouncycastle.util.encoders.Base64; import org.noreply.fancydress.misc.*; import org.noreply.fancydress.crypto.*; public class MMTPTrustManager implements X509TrustManager { - public MMTPTrustManager() { + /** + * Hash of the expected identity key. + */ + private byte[] identity; + + /** + * Create a new MMTPTrustManager instance. + * + * @param keyid fingerprint (== keyid, == hash of the key) of the identity key. + */ + public MMTPTrustManager(byte[] identity) { + this.identity = identity; } /** @@ -55,20 +70,31 @@ public class MMTPTrustManager implements X509TrustManager { public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - System.out.println("call to checkServerTrusted()\n"); - System.out.println("certs: " + chain.length); - for (int i=0; i