public static SSLContext forPin(String pinString) throws KeyManagementException, NoSuchAlgorithmException { return INSTANCE.ctxForPin(pinString); }
protected final SSLContext ctxForPin(String pinString) throws KeyManagementException, NoSuchAlgorithmException { return ctxForPins(pinString); }
protected final SSLContext ctxForPins(Collection<Pin> pins) throws KeyManagementException, NoSuchAlgorithmException { TrustManager trustManager = tmForPins(pins); return fromTrustManager(trustManager); }
public static X509TrustManager trustManagerForPins(String... pinStrings) { return INSTANCE.tmForPins(pinStrings); }
protected final X509TrustManager tmForPins(Collection<Pin> pins) { PinningTrustManager pinningTrustManager = new PinningTrustManager(pins); X509TrustManager trustManager = eventuallySpecialize(pinningTrustManager); return trustManager; }
/** * Do not use. * * @deprecated Please use the correctly named: {@link #trustManagerForPins(Collection)} */ @Deprecated public static X509TrustManager trustManagerforPins(Collection<Pin> pins) { return trustManagerForPins(pins); }
public static X509TrustManager trustManagerForPin(String pinString) { return INSTANCE.tmForPin(pinString); }
@Test(expected = CertificateNotPinnedException.class) public void shouldThrowIfNotPinned() throws CertificateException { X509TrustManager tm = JavaPinning.trustManagerForPin("CERTPLAIN:" + TestUtilities.PLAIN_CERTIFICATE_2); tm.checkServerTrusted(DUMMY_CHAIN, ""); }
@Test public void main() throws NoSuchAlgorithmException, KeyManagementException, IOException { SSLContext sc = JavaPinning.forPin("SHA256:a4bd7ea9bf474cc459266b82fdb07f648f5ddf4d8162baea895b91c96f831ab5"); Socket socket = new Socket("github.com", 443); SSLSocket sslSocket = (SSLSocket) sc.getSocketFactory().createSocket(socket, "github.com", 443, true); sslSocket.startHandshake(); String name = sslSocket.getSession().getPeerPrincipal().getName(); // CHECKSTYLE:OFF System.out.println(name); // CHECKSTYLE:ON OutputStream os = sslSocket.getOutputStream(); os.write("GET /".getBytes()); os.flush(); } }
protected final X509TrustManager tmForPin(String pinString) { return tmForPins(pinString); }
protected final X509TrustManager tmForPins(Collection<Pin> pins) { PinningTrustManager pinningTrustManager = new PinningTrustManager(pins); X509TrustManager trustManager = eventuallySpecialize(pinningTrustManager); return trustManager; }
/** * Do not use. * * @deprecated Please use the correctly named: {@link #trustManagerForPins(Collection)} */ @Deprecated public static X509TrustManager trustManagerforPins(Collection<Pin> pins) { return trustManagerForPins(pins); }
public static X509TrustManager trustManagerForPin(String pinString) { return INSTANCE.tmForPin(pinString); }
@Test public void shouldReportPinIfNotPinned() { X509TrustManager tm = JavaPinning.trustManagerForPin("CERTPLAIN:" + TestUtilities.PLAIN_CERTIFICATE_2); try { tm.checkServerTrusted(DUMMY_CHAIN, ""); fail(); } catch (CertificateException e) { // Assert that the message of the exception contains a hint how to pin the certificate final String dummyCertPin = "CERTPLAIN:" + TestUtilities.PLAIN_CERTIFICATE_1; assertTrue(e.getMessage().contains(dummyCertPin)); } } }
protected final SSLContext ctxForPins(String... pinStrings) throws KeyManagementException, NoSuchAlgorithmException { TrustManager trustManager = tmForPins(pinStrings); return fromTrustManager(trustManager); }
public static X509TrustManager trustManagerForPins(Collection<Pin> pins) { return INSTANCE.tmForPins(pins); }
public static SSLContext forPins(String... pinStrings) throws KeyManagementException, NoSuchAlgorithmException { return INSTANCE.ctxForPins(pinStrings); }
public static SSLContext forPin(String pinString) throws KeyManagementException, NoSuchAlgorithmException { return INSTANCE.ctxForPin(pinString); }
protected final SSLContext ctxForPins(String... pinStrings) throws KeyManagementException, NoSuchAlgorithmException { TrustManager trustManager = tmForPins(pinStrings); return fromTrustManager(trustManager); }
public static X509TrustManager trustManagerForPins(String... pinStrings) { return INSTANCE.tmForPins(pinStrings); }