Search in sources :

Example 11 with SSLFDProxy

use of org.mozilla.jss.nss.SSLFDProxy 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 12 with SSLFDProxy

use of org.mozilla.jss.nss.SSLFDProxy 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 13 with SSLFDProxy

use of org.mozilla.jss.nss.SSLFDProxy 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

SSLFDProxy (org.mozilla.jss.nss.SSLFDProxy)13 PRFDProxy (org.mozilla.jss.nss.PRFDProxy)11 SSLException (javax.net.ssl.SSLException)1 CryptoManager (org.mozilla.jss.CryptoManager)1 BufferProxy (org.mozilla.jss.nss.BufferProxy)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