Update structure for partials and examples
This commit is contained in:
parent
b1b3d6a960
commit
531ddf0721
89 changed files with 79 additions and 79 deletions
|
@ -0,0 +1,34 @@
|
|||
|
||||
public class MyTrustManager implements X509TrustManager {
|
||||
private final byte[] certHash;
|
||||
|
||||
public MyTrustManager(byte[] certHash) throws Exception {
|
||||
this.certHash = certHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType)
|
||||
throws CertificateException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain,
|
||||
String authType) throws CertificateException {
|
||||
byte[] digest = getCertificateDigest(chain[0]);
|
||||
String digestHex = formatHex(digest);
|
||||
|
||||
if (Arrays.equals(digest, certHash)) {
|
||||
System.err.println("info: accepting certificate: " + digestHex);
|
||||
} else {
|
||||
throw new CertificateException("certificate rejected: " +
|
||||
digestHex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue