Skip to content

Beryl 0.2.3: client certificates (mutual TLS)

Choose a tag to compare

@crimson-knight crimson-knight released this 25 Nov 23:42
357b10a

Client certificates (mutual TLS) in both directions.

  • A TLS server can ask for client certificates (mutual TLS), off by default.
    Context::Server#client_verify_mode= takes ClientVerifyMode::None,
    Optional (request; verify a chain when one is sent) or Required (an
    empty Certificate fails with certificate_required); verify_mode = VerifyMode::Peer maps to Required, as OpenSSL's server context takes it.
    Client chains are verified to client_ca_certificates= (PEM) or
    client_trust_store= by the new ClientCertificateVerifier (B4's
    ChainVerification with purpose clientAuth, digitalSignature key usage,
    no name check); client_certificate_verifier= replaces it. The
    CertificateRequest lists the schemes Beryl verifies and the trust store's
    root names (largest_certificate_authorities_bytesize, 16 KiB). The
    client's CertificateVerify is checked with the client context string over
    the transcript, and a bad signature ends the handshake with
    decrypt_error.
  • Socket::Server#peer_certificate returns the client's leaf (nil when none
    was asked for or sent), and #list_of_peer_certificates (alias
    #peer_certificate_chain) the chain.
  • Session tickets record the client's chain (ticket format 2; a format 1
    ticket gets a full handshake), so a resumed connection keeps its client
    identity. A server that asks for certificates verifies the chain again on
    resumption, and one that requires a certificate resumes only a session
    that had one.
  • BoGo: the shim runs server -verify-peer, -require-any-client-certificate,
    -verify-fail, -expect-peer-cert-file, -expect-verify-result and an
    empty -use-client-ca-list; the TLS 1.3 server client-certificate tests
    run and pass. tlsfuzzer runs test-tls13-certificate-request.py,
    test-tls13-certificate-verify.py,
    test-tls13-ecdsa-in-certificate-verify.py and
    test-tls13-eddsa-in-certificate-verify.py. The interop matrix adds
    OpenSSL s_client and the Go client presenting client certificates to the
    example server, which now takes --client-verify, --client-ca and
    --any-client-chain.
  • TLS client certificates (mutual TLS), client side. Context::Client
    gains certificate_chain= (PEM chain, leaf first), private_key=
    (PKCS #8, SEC 1 or PKCS #1), certified_key= and certified_key?, shaped
    like OpenSSL::SSL::Context. On a CertificateRequest the client picks the
    first signature scheme its key signs (P-256, RSA-PSS, Ed25519) that the
    request lists, and sends its chain and a CertificateVerify signed with the
    client context string (RFC 9846 §4.4.3) before its Finished. With no
    certificate, or no scheme in common, it sends an empty Certificate as
    before. A chain set without its key, or a key without its chain, raises
    TLS::Error naming the missing half. certificate_authorities is now
    parsed (an empty or malformed list is a decode_error) and otherwise read
    as information only.
  • BoGo: as a client the shim configures its certificate from -cert-file
    and -key-file, treats -use-old-client-cert-callback as neutral, and
    runs -verify-fail, -expect-verify-result, -expect-peer-cert-file
    and -require-any-client-certificate the way BoringSSL's shim does (its
    verify callback accepts any chain unless -verify-fail; the
    CertificateVerify signature is always checked). The client-side TLS 1.3
    ClientAuth, CertificateAuthorities, SignatureAlgorithms and
    CertificateVerification tests now run and pass (727 passed, up from 631);
    the TLS 1.2 variants they uncovered are disabled with the TLS 1.2 reason,
    and six TLS 1.3 SignDefault tests where BoringSSL aborts but Beryl sends
    an empty Certificate are disabled with that reason.
  • Interop: examples/https_client.cr takes --certificate-chain and
    --private-key; the matrix presents P-256, RSA and Ed25519 client
    certificates to openssl s_server -Verify 1 and to a Go server with
    tls.RequireAndVerifyClientCert (go_peer server -client-ca), each of
    which reports the verified subject.
Commit: 357b10ad61fdc0d795e1e390200ce3cdad6e2bfa
Tree: 326b2be3c3f9c2869f6a0dceca293d63459065fb
Tarball: beryl-0.2.3.tar.gz (git archive --format=tar.gz --prefix=beryl-0.2.3/ 357b10ad61fdc0d795e1e390200ce3cdad6e2bfa)
Tarball sha256: 4ed99b3cc22ecef6d08ad5d3f7074286f2cadafae90a69176a2609b5ee2703d9

The tarball was built twice from the commit and gave the same sha256 both times, and the copy attached here was downloaded again and matched.