Home / Class/ BoringSSLCertificateCallbackTask Class — netty Architecture

BoringSSLCertificateCallbackTask Class — netty Architecture

Architecture documentation for the BoringSSLCertificateCallbackTask class in BoringSSLCertificateCallbackTask.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  587238a8_8157_6925_b76e_7b541ca73374["BoringSSLCertificateCallbackTask"]
  0360e754_7b62_1d52_8a2a_39be8ca575af["BoringSSLCertificateCallbackTask.java"]
  587238a8_8157_6925_b76e_7b541ca73374 -->|defined in| 0360e754_7b62_1d52_8a2a_39be8ca575af
  2e9010ab_977d_2533_069d_6b284f50348b["BoringSSLCertificateCallbackTask()"]
  587238a8_8157_6925_b76e_7b541ca73374 -->|method| 2e9010ab_977d_2533_069d_6b284f50348b
  621521e7_e83e_eadc_e26f_067a0f5ff78f["runTask()"]
  587238a8_8157_6925_b76e_7b541ca73374 -->|method| 621521e7_e83e_eadc_e26f_067a0f5ff78f
  c0cf7802_25e9_8507_b389_c42b3b7405ed["destroy()"]
  587238a8_8157_6925_b76e_7b541ca73374 -->|method| c0cf7802_25e9_8507_b389_c42b3b7405ed

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLCertificateCallbackTask.java lines 21–73

final class BoringSSLCertificateCallbackTask extends BoringSSLTask {
    private final byte[] keyTypeBytes;
    private final byte[][] asn1DerEncodedPrincipals;
    private final String[] authMethods;
    private final BoringSSLCertificateCallback callback;

    // Accessed via JNI.
    private long key;
    private long chain;

    BoringSSLCertificateCallbackTask(long ssl, byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals,
                                     String[] authMethods, BoringSSLCertificateCallback callback) {
        // It is important that this constructor never throws. Be sure to not change this!
        super(ssl);
        // It's ok to not clone the arrays as we create these in JNI and not-reuse.
        this.keyTypeBytes = keyTypeBytes;
        this.asn1DerEncodedPrincipals = asn1DerEncodedPrincipals;
        this.authMethods = authMethods;
        this.callback = callback;
    }

    // See https://www.openssl.org/docs/man1.0.2/man3/SSL_set_cert_cb.html.
    @Override
    protected void runTask(long ssl, TaskCallback taskCallback) {
        try {
            long[] result = callback.handle(ssl, keyTypeBytes, asn1DerEncodedPrincipals, authMethods);
            if (result == null) {
                taskCallback.onResult(ssl, 0);
            } else {
                this.key = result[0];
                this.chain = result[1];
                taskCallback.onResult(ssl, 1);
            }
        } catch (Exception e) {
            // Just catch the exception and return 0 to fail the handshake.
            // The problem is that rethrowing here is really "useless" as we will process it as part of an openssl
            // c callback which needs to return 0 for an error to abort the handshake.
            taskCallback.onResult(ssl, 0);
        }
    }

    @Override
    protected void destroy() {
        if (key != 0) {
            BoringSSL.EVP_PKEY_free(key);
            key = 0;
        }
        if (chain != 0) {
            BoringSSL.CRYPTO_BUFFER_stack_free(chain);
            chain = 0;
        }
    }
}

Frequently Asked Questions

What is the BoringSSLCertificateCallbackTask class?
BoringSSLCertificateCallbackTask is a class in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLCertificateCallbackTask.java.
Where is BoringSSLCertificateCallbackTask defined?
BoringSSLCertificateCallbackTask is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLCertificateCallbackTask.java at line 21.

Analyze Your Own Codebase

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

Try Supermodel Free