Home / Function/ OpenSslKeyMaterial() — netty Function Reference

OpenSslKeyMaterial() — netty Function Reference

Architecture documentation for the OpenSslKeyMaterial() function in OpenSslKeyMaterialProvider.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a72ea4c3_53f7_2633_f091_7119e840622f["OpenSslKeyMaterial()"]
  738f20d6_5be5_1429_78fc_40bccc7b3b90["OpenSslKeyMaterialProvider"]
  a72ea4c3_53f7_2633_f091_7119e840622f -->|defined in| 738f20d6_5be5_1429_78fc_40bccc7b3b90
  style a72ea4c3_53f7_2633_f091_7119e840622f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialProvider.java lines 113–154

    OpenSslKeyMaterial chooseKeyMaterial(ByteBufAllocator allocator, String alias) throws Exception {
        X509Certificate[] certificates = keyManager.getCertificateChain(alias);
        if (certificates == null || certificates.length == 0) {
            return null;
        }

        PrivateKey key = keyManager.getPrivateKey(alias);
        PemEncoded encoded = PemX509Certificate.toPEM(allocator, true, certificates);
        long chainBio = 0;
        long pkeyBio = 0;
        long chain = 0;
        long pkey = 0;
        try {
            chainBio = toBIO(allocator, encoded.retain());
            chain = SSL.parseX509Chain(chainBio);

            OpenSslKeyMaterial keyMaterial;
            if (key instanceof OpenSslPrivateKey) {
                keyMaterial = ((OpenSslPrivateKey) key).newKeyMaterial(chain, certificates);
            } else {
                pkeyBio = toBIO(allocator, key);
                pkey = key == null ? 0 : SSL.parsePrivateKey(pkeyBio, password);
                keyMaterial = new DefaultOpenSslKeyMaterial(chain, pkey, certificates);
            }

            // See the chain and pkey to 0 so we will not release it as the ownership was
            // transferred to OpenSslKeyMaterial.
            chain = 0;
            pkey = 0;
            return keyMaterial;
        } finally {
            SSL.freeBIO(chainBio);
            SSL.freeBIO(pkeyBio);
            if (chain != 0) {
                SSL.freeX509Chain(chain);
            }
            if (pkey != 0) {
                SSL.freePrivateKey(pkey);
            }
            encoded.release();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does OpenSslKeyMaterial() do?
OpenSslKeyMaterial() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialProvider.java.
Where is OpenSslKeyMaterial() defined?
OpenSslKeyMaterial() is defined in handler/src/main/java/io/netty/handler/ssl/OpenSslKeyMaterialProvider.java at line 113.

Analyze Your Own Codebase

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

Try Supermodel Free