eu.geekplace.javapinning.JavaPinning Java Examples
The following examples show how to use
eu.geekplace.javapinning.JavaPinning.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTest.java From java-pinning with Apache License 2.0 | 5 votes |
@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(); }