Search in sources :

Example 11 with PRFDProxy

use of org.mozilla.jss.nss.PRFDProxy in project jss by dogtagpki.

the class TestRawSSL method TestSSLGetPreliminaryChannelInfo.

public static void TestSSLGetPreliminaryChannelInfo() throws Exception {
    PRFDProxy fd = PR.NewTCPSocket();
    assert (fd != null);
    SSLFDProxy ssl_fd = SSL.ImportFD(null, fd);
    assert (ssl_fd != null);
    SSLPreliminaryChannelInfo r = SSL.GetPreliminaryChannelInfo(ssl_fd);
    assert (r != null);
    assert (r.haveProtocolVersion() == false);
    assert (r.haveCipherSuite() == false);
    assert (r.haveZeroRttCipherSuite() == false);
    assert (r.havePeerAuth() == false);
    System.out.println(r.toString());
    assert (PR.Close(ssl_fd) == PR.SUCCESS);
}
Also used : PRFDProxy(org.mozilla.jss.nss.PRFDProxy) SSLFDProxy(org.mozilla.jss.nss.SSLFDProxy) SSLPreliminaryChannelInfo(org.mozilla.jss.nss.SSLPreliminaryChannelInfo)

Example 12 with PRFDProxy

use of org.mozilla.jss.nss.PRFDProxy in project jss by dogtagpki.

the class TestRawSSL method TestSSLSetURL.

public static void TestSSLSetURL() throws Exception {
    PRFDProxy fd = PR.NewTCPSocket();
    assert (fd != null);
    SSLFDProxy ssl_fd = SSL.ImportFD(null, fd);
    assert (ssl_fd != null);
    assert (SSL.SetURL(ssl_fd, "https://google.com") == SSL.SECSuccess);
    assert (PR.Close(ssl_fd) == PR.SUCCESS);
}
Also used : PRFDProxy(org.mozilla.jss.nss.PRFDProxy) SSLFDProxy(org.mozilla.jss.nss.SSLFDProxy)

Example 13 with PRFDProxy

use of org.mozilla.jss.nss.PRFDProxy in project jss by dogtagpki.

the class TestRawSSL method TestSSLResetHandshake.

public static void TestSSLResetHandshake() throws Exception {
    PRFDProxy fd = PR.NewTCPSocket();
    assert (fd != null);
    SSLFDProxy ssl_fd = SSL.ImportFD(null, fd);
    assert (SSL.ResetHandshake(ssl_fd, false) == SSL.SECSuccess);
    assert (PR.Close(ssl_fd) == PR.SUCCESS);
}
Also used : PRFDProxy(org.mozilla.jss.nss.PRFDProxy) SSLFDProxy(org.mozilla.jss.nss.SSLFDProxy)

Example 14 with PRFDProxy

use of org.mozilla.jss.nss.PRFDProxy in project jss by dogtagpki.

the class TestRawSSL method TestSSLOptions.

public static void TestSSLOptions() throws Exception {
    PRFDProxy fd = PR.NewTCPSocket();
    assert (fd != null);
    SSLFDProxy ssl_fd = SSL.ImportFD(null, fd);
    assert (ssl_fd != null);
    // 8 == SSL_ENABLE_SSL3; disable it
    assert (SSL.OptionSet(ssl_fd, 8, 0) == SSL.SECSuccess);
    // Validate that the set worked.
    assert (SSL.OptionGet(ssl_fd, 8) == SSL.SECSuccess);
    // Renable SSL_ENABLE_SSL3 and validate it worked
    assert (SSL.OptionSet(ssl_fd, 8, 1) == SSL.SECSuccess);
    assert (SSL.OptionGet(ssl_fd, 8) == 1);
    // Ensure that setting an invalid option fails
    assert (SSL.OptionSet(ssl_fd, 799999, 0) != SSL.SECSuccess);
    // Ensure that getting an invalid option fails
    try {
        SSL.OptionGet(ssl_fd, 79999999);
        assert (false);
    } catch (Exception e) {
        assert (true);
    }
    assert (PR.Close(ssl_fd) == PR.SUCCESS);
}
Also used : PRFDProxy(org.mozilla.jss.nss.PRFDProxy) SSLFDProxy(org.mozilla.jss.nss.SSLFDProxy)

Example 15 with PRFDProxy

use of org.mozilla.jss.nss.PRFDProxy in project jss by dogtagpki.

the class TestRawSSL method TestSSLCipherPref.

public static void TestSSLCipherPref() throws Exception {
    PRFDProxy fd = PR.NewTCPSocket();
    assert (fd != null);
    SSLFDProxy ssl_fd = SSL.ImportFD(null, fd);
    assert (ssl_fd != null);
    int cipher = SSLCipher.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384.getID();
    // Ensure that setting a ciphersuite works correctly
    assert (SSL.CipherPrefSet(ssl_fd, cipher, false) == SSL.SECSuccess);
    assert (SSL.CipherPrefGet(ssl_fd, cipher) == false);
    assert (SSL.CipherPrefSet(ssl_fd, cipher, true) == SSL.SECSuccess);
    assert (SSL.CipherPrefGet(ssl_fd, cipher) == true);
    // Ensure that using an invalid ciphersuite fails.
    assert (SSL.CipherPrefSet(ssl_fd, 0x999999, false) == SSL.SECFailure);
    try {
        SSL.CipherPrefGet(ssl_fd, 0x999999);
        assert (false);
    } catch (Exception e) {
        assert (true);
    }
    assert (PR.Close(ssl_fd) == PR.SUCCESS);
}
Also used : PRFDProxy(org.mozilla.jss.nss.PRFDProxy) SSLFDProxy(org.mozilla.jss.nss.SSLFDProxy)

Aggregations

PRFDProxy (org.mozilla.jss.nss.PRFDProxy)17 SSLFDProxy (org.mozilla.jss.nss.SSLFDProxy)11 BufferProxy (org.mozilla.jss.nss.BufferProxy)2 SSLException (javax.net.ssl.SSLException)1 CryptoManager (org.mozilla.jss.CryptoManager)1 SSLChannelInfo (org.mozilla.jss.nss.SSLChannelInfo)1 SSLPreliminaryChannelInfo (org.mozilla.jss.nss.SSLPreliminaryChannelInfo)1 SecurityStatusResult (org.mozilla.jss.nss.SecurityStatusResult)1 PK11Cert (org.mozilla.jss.pkcs11.PK11Cert)1 PK11PrivKey (org.mozilla.jss.pkcs11.PK11PrivKey)1 SSLAlertEvent (org.mozilla.jss.ssl.SSLAlertEvent)1