Skip to content

Add relax-rsa-key-usage feature to restore historical RSA keyUsage - #512

Open
johnhurt wants to merge 1 commit into
cloudflare:masterfrom
johnhurt:kbg/relax-rsa-key-usage
Open

Add relax-rsa-key-usage feature to restore historical RSA keyUsage #512
johnhurt wants to merge 1 commit into
cloudflare:masterfrom
johnhurt:kbg/relax-rsa-key-usage

Conversation

@johnhurt

Copy link
Copy Markdown
Contributor

BoringSSL 5.x includes an update to openssl that changed SSL_CONFIG::enforce_rsa_key_usage to default to true, making client-side RSA leaf keyUsage mismatches a fatal handshake error (KEY_USAGE_BIT_INCORRECT). Many real-world origins serve certificates whose keyUsage does not include the bit required by the negotiated cipher suite; OpenSSL and prior BoringSSL pins accepted them.

This adds a new relax-rsa-key-usage Cargo feature that applies a build-time patch restoring the historical default (false). When the feature is not enabled, the BoringSSL 5.x strict behaviour is preserved. Non-RSA keyUsage enforcement is unaffected in either case.

@cjpatton cjpatton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can you update CI to make sure the patch is tested? Also consider adding a unit test with a cert that would validate with and without this feature.

Comment thread boring-sys/Cargo.toml Outdated
underscore-wildcards = []

# Restores the historical BoringSSL default of not enforcing RSA keyUsage
# during TLS handshakes. BoringSSL 5.x changed `enforce_rsa_key_usage` to

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number refers to the boring crate, not BoringSSL, correct? It might be more helpful to refer to the value of BORINGSSL_API_VERSION in the BoringSSL repo itself (include/openssl/base.h).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise for the commit message for the new patch.

@johnhurt

Copy link
Copy Markdown
Contributor Author

Good call. I'll take care of both.

@johnhurt
johnhurt force-pushed the kbg/relax-rsa-key-usage branch from 8bf3d4b to b971e57 Compare June 26, 2026 20:44
@johnhurt

Copy link
Copy Markdown
Contributor Author

Okay, those requested changes should be handled now. I'm getting a ci error, but it seems like a flake

@cjpatton

cjpatton commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

I kicked the job and it failed the same way. Looks like an issue with CI itself, probably just needs updating.

Comment thread boring-sys/Cargo.toml Outdated
# (KEY_USAGE_BIT_INCORRECT). Enabling this feature applies a build-time
# patch that sets the default back to `false`, so RSA keyUsage mismatches
# are non-fatal. Non-RSA keyUsage enforcement is unaffected.
relax-rsa-key-usage = []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a rename that allows us to reuse this for other changes like this.

Suggested change
relax-rsa-key-usage = []
relax-cert-validation = []

Comment thread boring/test/generate-rsa-key-usage-relaxed-certs.sh
@cjpatton

Copy link
Copy Markdown
Collaborator

@johnhurt I just merged #516, which should fix CI once you rebase.

…e default

BoringSSL starting with BORINGSSL_API_VERSION 19 (see

include/openssl/base.h) changed SSL_CONFIG::enforce_rsa_key_usage to

default to true, making client-side RSA leaf keyUsage mismatches a fatal

handshake error (KEY_USAGE_BIT_INCORRECT). Many real-world origins serve

certificates whose keyUsage does not include the bit required by the

negotiated cipher suite; OpenSSL and prior BoringSSL pins accepted them.

This adds a new `relax-cert-validation` Cargo feature that applies a

build-time patch restoring the historical default (false). When the

feature is not enabled, the strict BoringSSL behaviour is preserved.

Non-RSA keyUsage enforcement is unaffected in either case.

A unit test verifies that a TLS 1.2 ECDHE-RSA server certificate with

keyUsage missing the digitalSignature bit is rejected by default and

accepted when the feature is enabled.
@johnhurt
johnhurt force-pushed the kbg/relax-rsa-key-usage branch from b971e57 to 0807b30 Compare July 28, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants