Search in sources :

Example 1 with DefaultTlsClient

use of org.openecard.bouncycastle.tls.DefaultTlsClient in project open-ecard by ecsec.

the class StreamHttpClientConnectionTest method testRequestHttpsGoogle.

@Test
public void testRequestHttpsGoogle() throws IOException, HttpException {
    final String hostName = "www.google.com";
    // open connection
    Socket socket = new Socket(hostName, 443);
    assertTrue(socket.isConnected());
    DefaultTlsClient tlsClient = new DefaultTlsClientImpl(new BcTlsCrypto(rand)) {

        @Override
        protected Vector getSNIServerNames() {
            return new Vector(Collections.singletonList(hostName));
        }
    };
    TlsClientProtocol handler = new TlsClientProtocol(socket.getInputStream(), socket.getOutputStream());
    handler.connect(tlsClient);
    StreamHttpClientConnection conn = new StreamHttpClientConnection(handler.getInputStream(), handler.getOutputStream());
    assertTrue(conn.isOpen());
    consumeEntity(conn, hostName, 2);
}
Also used : TlsClientProtocol(org.openecard.bouncycastle.tls.TlsClientProtocol) DefaultTlsClient(org.openecard.bouncycastle.tls.DefaultTlsClient) BcTlsCrypto(org.openecard.bouncycastle.tls.crypto.impl.bc.BcTlsCrypto) Vector(java.util.Vector) Socket(java.net.Socket) Test(org.testng.annotations.Test)

Aggregations

Socket (java.net.Socket)1 Vector (java.util.Vector)1 DefaultTlsClient (org.openecard.bouncycastle.tls.DefaultTlsClient)1 TlsClientProtocol (org.openecard.bouncycastle.tls.TlsClientProtocol)1 BcTlsCrypto (org.openecard.bouncycastle.tls.crypto.impl.bc.BcTlsCrypto)1 Test (org.testng.annotations.Test)1