Skip to content

Implement TLS1.3 delayed client cert requests on Linux - #64268

Merged
bartonjs merged 7 commits into
dotnet:mainfrom
rzikm:55757_nego-tls-1.3
Feb 9, 2022
Merged

Implement TLS1.3 delayed client cert requests on Linux#64268
bartonjs merged 7 commits into
dotnet:mainfrom
rzikm:55757_nego-tls-1.3

Conversation

@rzikm

@rzikmrzikm commented Jan 25, 2022

Copy link
Copy Markdown
Member

Fixes#55757

This PR adds the NegotiateClientCertificateAsync support for TLS1.3 on Linux

The changes in this PR depend on changes made in #63945, so this PR will need to stay in draft state until that one is merged.
https://github.com/dotnet/runtime/pull/64268/files#diff-5d47fb42fd96c09e13b52482e126d7a282513646feb5f672108dbbd7dd0d5f4aR543-R545

The changes also should contribute to #58927, I was able to reproduce the hang in SslStream_NegotiateClientCertificateAsyncTls13_Succeeds when using OpenSSL and Linux.
https://github.com/dotnet/runtime/pull/64268/files#diff-1d28e92dd65ace08e351f991ffd5da78f606a6bc4f212160df97d5012bd7cdc9R577-R579

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/ncl, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #55757

This PR adds the NegotiateClientCertificateAsync support for TLS1.3 on Linux

The changes in this PR depend on changes made in #63945, so this PR will need to stay in draft state until that one is merged.

The changes also should contribute to #58927, I was able to reproduce the hang in SslStream_NegotiateClientCertificateAsyncTls13_Succeeds when using OpenSSL and Linux.

Author:rzikm
Assignees:-
Labels:

area-System.Net.Security

Milestone:-

@rzikmrzikm changed the title Use correct API on TLS1.3 for delayed client cert requests (WIP)Implement TLS1.3 delayed client cert requests on LinuxJan 25, 2022
@rzikmrzikm added the os-linux Linux OS (any supported distro) label Jan 25, 2022

@wfurtwfurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks like good start. I left few early comments

Comment threadsrc/native/libs/System.Security.Cryptography.Native/configure.cmake Outdated
Comment threadsrc/native/libs/System.Security.Cryptography.Native/opensslshim.h Outdated
@rzikm
rzikmforce-pushed the 55757_nego-tls-1.3 branch 3 times, most recently from 709984b to 6f64c53CompareJanuary 27, 2022 13:24
@rzikm
rzikm requested a review from wfurtJanuary 27, 2022 13:56
@rzikm
rzikm marked this pull request as ready for review January 27, 2022 19:33
@rzikm

Copy link
Copy Markdown
MemberAuthor

Looks like we have test failures on Ubuntu 18.04, possibly becuase we are calling SSL_renegotiate on TLS 1.3 session. The only way this can happen IMO is that we are compiling against older openssl headers and thus the branch calling SSL_verify_client_post_handshake is left out due to preprocessor define.

CI Log
===========================================================================================================
/datadisks/disk1/work/9FBA08A2/w/A8980923/e /datadisks/disk1/work/9FBA08A2/w/A8980923/e
Discovering: System.Net.Security.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Net.Security.Tests (found 290 of 475 test cases)
Starting: System.Net.Security.Tests (parallel test collections = on, max threads = 2)
System.Net.Security.Tests.SslStreamEKUTest.SslStream_SelfSignedClientEKUClientAuth_Ok [SKIP]
Condition(s) not met: "IsRootCertificateInstalled"
System.Net.Security.Tests.SslStreamEKUTest.SslStream_ServerEKUClientAuth_Fails [SKIP]
Condition(s) not met: "IsRootCertificateInstalled"
System.Net.Security.Tests.SslStreamEKUTest.SslStream_ClientEKUServerAuth_Fails [SKIP]
Condition(s) not met: "IsRootCertificateInstalled"
System.Net.Security.Tests.SslStreamEKUTest.SslStream_NoEKUServerAuth_Ok [SKIP]
Condition(s) not met: "IsRootCertificateInstalled"
System.Net.Security.Tests.SslStreamEKUTest.SslStream_NoEKUClientAuth_Ok [SKIP]
Condition(s) not met: "IsRootCertificateInstalled"
System.Net.Security.Tests.SslStreamNetworkStreamTest.SslStream_NegotiateClientCertificateAsyncTls13_Succeeds(sendClientCertificate: True) [FAIL]
Interop+Crypto+OpenSslCryptographicException : error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version
Stack Trace:
/_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(298,0): at System.Net.Security.SslStream.<RenegotiateAsync>d__172`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
/_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs(463,0): at System.Net.Security.Tests.SslStreamNetworkStreamTest.SslStream_NegotiateClientCertificateAsyncTls13_Succeeds(Boolean sendClientCertificate)
--- End of stack trace from previous location ---
System.Net.Security.Tests.SslStreamNetworkStreamTest.SslStream_NegotiateClientCertificateAsyncTls13_Succeeds(sendClientCertificate: False) [FAIL]
Interop+Crypto+OpenSslCryptographicException : error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version
Stack Trace:
/_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(298,0): at System.Net.Security.SslStream.<RenegotiateAsync>d__172`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
/_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs(463,0): at System.Net.Security.Tests.SslStreamNetworkStreamTest.SslStream_NegotiateClientCertificateAsyncTls13_Succeeds(Boolean sendClientCertificate)
--- End of stack trace from previous location ---
Finished: System.Net.Security.Tests
=== TEST EXECUTION SUMMARY ===

@rzikm
rzikmforce-pushed the 55757_nego-tls-1.3 branch 2 times, most recently from 0698b85 to 0996fcdCompareFebruary 2, 2022 12:01
@rzikm

rzikm commented Feb 2, 2022

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rzikm

rzikm commented Feb 3, 2022

Copy link
Copy Markdown
MemberAuthor

CI failures are unrelated:

  • System.Net.Sockets.Tests.SocketAsyncEventArgsTest.AcceptAsync_WithTooSmallReceiveBuffer_Failure
  • System.Net.Security.Tests.TelemetryTest.EventSource_SuccessfulHandshake_LogsStartStop

Comment threadsrc/native/libs/System.Security.Cryptography.Native/opensslshim.h Outdated
Comment threadsrc/native/libs/System.Security.Cryptography.Native/opensslshim.h Outdated
Comment threadsrc/native/libs/System.Security.Cryptography.Native/pal_ssl.c Outdated
Comment on lines 82 to 83

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If no special #if is required for these prototypes, they should be sorted alphabetically in this block.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Should be fixed now

@rzikm

rzikm commented Feb 8, 2022

Copy link
Copy Markdown
MemberAuthor

I think the code is ready now for (hopefully last) round of reviews

@rzikm
rzikm requested a review from bartonjsFebruary 8, 2022 19:29

@wfurtwfurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The SslStream part look good to me. I'll deferrer final judgement on the PAL to @bartonjs.

@rzikm

rzikm commented Feb 9, 2022

Copy link
Copy Markdown
MemberAuthor

Failing test is #64964
build runtime-libraries enterprise-linux failure seems unrelated

 [ 45%] Building ASM object vm/wks/CMakeFiles/cee_wks_core.dir/__/amd64/jithelpers_fastwritebarriers.S.o
/repo/src/coreclr/vm/amd64/jithelpers_fast.S:456:9: error: invalid operand for instruction
mov r10, 0xCDCDCDCDCDCDCDCD
^

@rzikm

rzikm commented Feb 9, 2022

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

rzikmand others added 7 commits February 9, 2022 11:40
Fix native shims on older OpenSSL versions
Remove unneeded hacks
Remove redundant PlatformSpecificAttribute
Merge CryptoNative_SslVerifyClientPostHandshake to CryptoNative_SslRenegotiate
Reenable test on Windows 11
Revert unwanted changes
Advertise post-handshake auth if client provided a cert
Fix compilation against older OpenSSL versions
Fix trailing whitespace
Fix compilation on older versions
Add missing define
@bartonjs
bartonjs merged commit aaaa2a7 into dotnet:mainFeb 9, 2022
@rzikmrzikm removed their assignment Feb 16, 2022
@ghostghost locked as resolved and limited conversation to collaborators Mar 18, 2022
@karelzkarelz added this to the 7.0.0 milestone Apr 8, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Securityos-linuxLinux OS (any supported distro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SslStream delayed client certificate with TLS 1.3 on Linux

5 participants

@rzikm@stephentoub@bartonjs@wfurt@karelz