Search in sources :

Example 1 with TlsContextPkcs11Options

use of software.amazon.awssdk.crt.io.TlsContextPkcs11Options in project aws-crt-java by awslabs.

the class TlsContextOptionsTest method testMtlsPkcs11.

@Test
public void testMtlsPkcs11() {
    Assume.assumeTrue(System.getProperty("NETWORK_TESTS_DISABLED") == null);
    Pkcs11LibTest.assumeEnvironmentSetUpForPkcs11Tests();
    try (Pkcs11Lib pkcs11Lib = new Pkcs11Lib(Pkcs11LibTest.TEST_PKCS11_LIB);
        TlsContextPkcs11Options pkcs11Options = new TlsContextPkcs11Options(pkcs11Lib).withUserPin(Pkcs11LibTest.TEST_PKCS11_PIN).withTokenLabel(Pkcs11LibTest.TEST_PKCS11_TOKEN_LABEL).withPrivateKeyObjectLabel(Pkcs11LibTest.TEST_PKCS11_PKEY_LABEL).withCertificateFilePath(Pkcs11LibTest.TEST_PKCS11_CERT_FILE);
        TlsContextOptions tlsOptions = TlsContextOptions.createWithMtlsPkcs11(pkcs11Options);
        TlsContext tls = new TlsContext(tlsOptions)) {
    } catch (CrtRuntimeException ex) {
        // This is expected to fail on platforms where we don't yet support mTLS with PKCS#11
        assertEquals("AWS_ERROR_UNIMPLEMENTED", ex.errorName);
    }
}
Also used : TlsContextOptions(software.amazon.awssdk.crt.io.TlsContextOptions) CrtRuntimeException(software.amazon.awssdk.crt.CrtRuntimeException) Pkcs11Lib(software.amazon.awssdk.crt.io.Pkcs11Lib) TlsContext(software.amazon.awssdk.crt.io.TlsContext) TlsContextPkcs11Options(software.amazon.awssdk.crt.io.TlsContextPkcs11Options) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CrtRuntimeException (software.amazon.awssdk.crt.CrtRuntimeException)1 Pkcs11Lib (software.amazon.awssdk.crt.io.Pkcs11Lib)1 TlsContext (software.amazon.awssdk.crt.io.TlsContext)1 TlsContextOptions (software.amazon.awssdk.crt.io.TlsContextOptions)1 TlsContextPkcs11Options (software.amazon.awssdk.crt.io.TlsContextPkcs11Options)1