Skip to content

Use existing session context if new is actually NULL#2946

Merged
torben-hansen merged 1 commit intoaws:mainfrom
torben-hansen:null_check_ssl_set_ssl_ctx
Jan 20, 2026
Merged

Use existing session context if new is actually NULL#2946
torben-hansen merged 1 commit intoaws:mainfrom
torben-hansen:null_check_ssl_set_ssl_ctx

Conversation

@torben-hansen
Copy link
Copy Markdown
Contributor

Issues:

P369474299

Description of changes:

SSL_set_SSL_CTX() doesn't currently tolerate the ctx argument being NULL (it would just crash in some cases). I was pondering handling this by just explicitly error out if it was NULL. But I realised upstream OpenSSL has a different behaviour: falls back to existing session context from ssl.

This is unnecessary complexity, but in the name of interoperability I did that instead of flipping to an error state.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@torben-hansen torben-hansen requested a review from a team as a code owner January 17, 2026 00:09
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.10%. Comparing base (75a3e8b) to head (05fba68).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2946      +/-   ##
==========================================
- Coverage   78.11%   78.10%   -0.01%     
==========================================
  Files         679      679              
  Lines      117949   117949              
  Branches    16599    16598       -1     
==========================================
- Hits        92130    92122       -8     
- Misses      24930    24939       +9     
+ Partials      889      888       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@torben-hansen torben-hansen enabled auto-merge (squash) January 20, 2026 20:11
Copy link
Copy Markdown
Contributor

@geedo0 geedo0 left a comment

Choose a reason for hiding this comment

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

@torben-hansen torben-hansen merged commit 7487ad1 into aws:main Jan 20, 2026
470 of 478 checks passed
haproxy-mirror pushed a commit to haproxy/haproxy that referenced this pull request Jan 21, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.
@justsmth justsmth mentioned this pull request Jan 21, 2026
justsmth added a commit that referenced this pull request Jan 22, 2026
### Description of changes: 
Prepare AWS-LC v1.67.0

#### What's Changed
* Migrate Wycheproof test vectors for ECDSA, RSA PKCS#1, and some more
by @sgmenda in #2887
* increase timeout for SDE tests by @sgmenda in
#2936
* Rename volatile state/memory to unique state/memory by @torben-hansen
in #2935
* Fix failing Windows Docker image build by @nhatnghiho in
#2931
* Service Indicator: Add error call trampoline to avoid delocator issue
by @jakemas in #2920
* Add support for Big Endian in ACVP tool by @samuel40791765 in
#2938
* AES-GCM: Add function pointer trampolines to avoid delocator issue by
@jakemas in #2919
* Use already defined macro for no inline by @torben-hansen in
#2942
* Remove Kyber completely by @torben-hansen in
#2941
* Windows 7 support by @justsmth in
#2940
* Import mldsa-native by @jakemas in
#2902
* Use existing session context if new is actually NULL by @torben-hansen
in #2946
* Integrate Wycheproof ML-KEM test vectors by @sgmenda in
#2891
* Avoid cross-compilation build failure by @justsmth in
#2944


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
FireBurn pushed a commit to FireBurn/haproxy that referenced this pull request Jan 24, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.

(cherry picked from commit fbc98eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a7218df)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit da95d0e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
FireBurn pushed a commit to FireBurn/haproxy that referenced this pull request Jan 24, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.

(cherry picked from commit fbc98eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a7218df)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit da95d0e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ba87a9a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7c08e35)
[cf: applied on ssl_sock.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
FireBurn pushed a commit to FireBurn/haproxy that referenced this pull request Jan 24, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.

(cherry picked from commit fbc98eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
FireBurn pushed a commit to FireBurn/haproxy that referenced this pull request Jan 24, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.

(cherry picked from commit fbc98eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a7218df)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit da95d0e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ba87a9a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
FireBurn pushed a commit to FireBurn/haproxy that referenced this pull request Jan 24, 2026
It was reported by Przemyslaw Bromber that using the "generate-certificates"
option combined with AWS-LC would crash HAProxy when a request is done with a
SNI longer than 64 bytes.

The problem is that the certificate is generated with a CN greater than 64
bytes which results in ssl_sock_do_create_cert() returning NULL. This
NULL value being passed to SSL_set_SSL_CTX.

With OpenSSL, passing a NULL SSL_CTX does not seem to be an issue as it
would just ignore it.

With AWS_LC, passing a NULL seems to crash the function. This was
reported to upstream AWS-LC and fixed in patch 7487ad1dcd8
aws/aws-lc#2946.

This must be backported in every branches.

(cherry picked from commit fbc98eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a7218df)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
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.

4 participants