testChooseOpenSslPrivateKeyMaterial() — netty Function Reference
Architecture documentation for the testChooseOpenSslPrivateKeyMaterial() function in OpenSslKeyMaterialProviderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ae9ee12b_27b8_9225_c9e1_08cd33258ea2["testChooseOpenSslPrivateKeyMaterial()"] 014487c2_548f_89a4_daad_07995dfebf3f["OpenSslKeyMaterialProviderTest"] ae9ee12b_27b8_9225_c9e1_08cd33258ea2 -->|defined in| 014487c2_548f_89a4_daad_07995dfebf3f e168e670_6981_6688_8f4a_4f06025ea28e["OpenSslKeyMaterialProvider()"] ae9ee12b_27b8_9225_c9e1_08cd33258ea2 -->|calls| e168e670_6981_6688_8f4a_4f06025ea28e a2ed611d_7cd1_c3a3_5247_820028b57f09["SingleKeyManager()"] ae9ee12b_27b8_9225_c9e1_08cd33258ea2 -->|calls| a2ed611d_7cd1_c3a3_5247_820028b57f09 style ae9ee12b_27b8_9225_c9e1_08cd33258ea2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java lines 139–189
@Test
public void testChooseOpenSslPrivateKeyMaterial() throws Exception {
PrivateKey privateKey;
try (InputStream keyInputStream = getClass().getResourceAsStream("localhost_server.key")) {
privateKey = SslContext.toPrivateKey(
keyInputStream,
null);
}
assertNotNull(privateKey);
assertEquals("PKCS#8", privateKey.getFormat());
try (InputStream resourceAsStream = getClass().getResourceAsStream("localhost_server.pem")) {
final X509Certificate[] certChain = SslContext.toX509Certificates(resourceAsStream);
assertNotNull(certChain);
PemEncoded pemKey = null;
long pkeyBio = 0L;
OpenSslPrivateKey sslPrivateKey;
try {
pemKey = PemPrivateKey.toPEM(ByteBufAllocator.DEFAULT, true, privateKey);
pkeyBio = ReferenceCountedOpenSslContext.toBIO(ByteBufAllocator.DEFAULT, pemKey.retain());
sslPrivateKey = new OpenSslPrivateKey(SSL.parsePrivateKey(pkeyBio, null));
} finally {
ReferenceCountUtil.safeRelease(pemKey);
if (pkeyBio != 0L) {
SSL.freeBIO(pkeyBio);
}
}
final String keyAlias = "key";
OpenSslKeyMaterialProvider provider = new OpenSslKeyMaterialProvider(
new SingleKeyManager(keyAlias, sslPrivateKey, certChain),
null);
OpenSslKeyMaterial material = provider.chooseKeyMaterial(ByteBufAllocator.DEFAULT, keyAlias);
assertNotNull(material);
assertEquals(2, sslPrivateKey.refCnt());
assertEquals(1, material.refCnt());
assertTrue(material.release());
assertEquals(1, sslPrivateKey.refCnt());
// Can get material multiple times from the same key
material = provider.chooseKeyMaterial(ByteBufAllocator.DEFAULT, keyAlias);
assertNotNull(material);
assertEquals(2, sslPrivateKey.refCnt());
assertTrue(material.release());
assertTrue(sslPrivateKey.release());
assertEquals(0, sslPrivateKey.refCnt());
assertEquals(0, material.refCnt());
assertEquals(0, ((OpenSslPrivateKey.OpenSslPrivateKeyMaterial) material).certificateChain);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testChooseOpenSslPrivateKeyMaterial() do?
testChooseOpenSslPrivateKeyMaterial() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java.
Where is testChooseOpenSslPrivateKeyMaterial() defined?
testChooseOpenSslPrivateKeyMaterial() is defined in handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java at line 139.
What does testChooseOpenSslPrivateKeyMaterial() call?
testChooseOpenSslPrivateKeyMaterial() calls 2 function(s): OpenSslKeyMaterialProvider, SingleKeyManager.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free