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);
}
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);
}
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);
}
Aggregations