Home / Function/ setKeyMaterial() — netty Function Reference

setKeyMaterial() — netty Function Reference

Architecture documentation for the setKeyMaterial() function in ReferenceCountedOpenSslContext.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  3ed85459_5fc7_ea62_077b_f651f59ccc8a["setKeyMaterial()"]
  a8fb0f76_e201_5987_db10_2b8b0b47e791["ReferenceCountedOpenSslContext"]
  3ed85459_5fc7_ea62_077b_f651f59ccc8a -->|defined in| a8fb0f76_e201_5987_db10_2b8b0b47e791
  2cd31a19_5ca6_d5ce_61fe_753af4367e31["toBIO()"]
  3ed85459_5fc7_ea62_077b_f651f59ccc8a -->|calls| 2cd31a19_5ca6_d5ce_61fe_753af4367e31
  9cdbea9b_10b9_18cf_5e6b_9e674b461a05["freeBio()"]
  3ed85459_5fc7_ea62_077b_f651f59ccc8a -->|calls| 9cdbea9b_10b9_18cf_5e6b_9e674b461a05
  4bd0abd9_b8ec_3db0_ec88_b0976da28e9e["release()"]
  3ed85459_5fc7_ea62_077b_f651f59ccc8a -->|calls| 4bd0abd9_b8ec_3db0_ec88_b0976da28e9e
  style 3ed85459_5fc7_ea62_077b_f651f59ccc8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java lines 912–946

    static void setKeyMaterial(long ctx, X509Certificate[] keyCertChain, PrivateKey key, String keyPassword)
            throws SSLException {
         /* Load the certificate file and private key. */
        long keyBio = 0;
        long keyCertChainBio = 0;
        long keyCertChainBio2 = 0;
        PemEncoded encoded = null;
        try {
            // Only encode one time
            encoded = PemX509Certificate.toPEM(ByteBufAllocator.DEFAULT, true, keyCertChain);
            keyCertChainBio = toBIO(ByteBufAllocator.DEFAULT, encoded.retain());
            keyCertChainBio2 = toBIO(ByteBufAllocator.DEFAULT, encoded.retain());

            if (key != null) {
                keyBio = toBIO(ByteBufAllocator.DEFAULT, key);
            }

            SSLContext.setCertificateBio(
                    ctx, keyCertChainBio, keyBio,
                    keyPassword == null ? StringUtil.EMPTY_STRING : keyPassword);
            // We may have more then one cert in the chain so add all of them now.
            SSLContext.setCertificateChainBio(ctx, keyCertChainBio2, true);
        } catch (SSLException e) {
            throw e;
        } catch (Exception e) {
            throw new SSLException("failed to set certificate and key", e);
        } finally {
            freeBio(keyBio);
            freeBio(keyCertChainBio);
            freeBio(keyCertChainBio2);
            if (encoded != null) {
                encoded.release();
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does setKeyMaterial() do?
setKeyMaterial() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java.
Where is setKeyMaterial() defined?
setKeyMaterial() is defined in handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java at line 912.
What does setKeyMaterial() call?
setKeyMaterial() calls 3 function(s): freeBio, release, toBIO.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free