This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use libcurl+openssl to support TLS client certs
Make curlHandler support Client Certificates when the linked libcurl's ssl backend is compatible with openssl. CurlHandler is also updated to support ChannelBindingToken
- Loading branch information
Showing
26 changed files
with
872 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Net.Security; | ||
using System.Runtime.InteropServices; | ||
using System.Security.Authentication; | ||
using System.Security.Authentication.ExtendedProtection; | ||
using System.Security.Cryptography; | ||
using Microsoft.Win32.SafeHandles; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Ssl | ||
{ | ||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern void SetProtocolOptions(SafeSslContextHandle ctx, SslProtocols protocols); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern int SslCtxUseCertificate(SafeSslContextHandle ctx, SafeX509Handle certPtr); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern int SslCtxUsePrivateKey(SafeSslContextHandle ctx, SafeEvpPKeyHandle keyPtr); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern int SslCtxCheckPrivateKey(SafeSslContextHandle ctx); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern void SslCtxSetQuietShutdown(SafeSslContextHandle ctx); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern void SslCtxSetVerify(SafeSslContextHandle ctx, SslCtxSetVerifyCallback callback); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern void SetEncryptionPolicy(SafeSslContextHandle ctx, EncryptionPolicy policy); | ||
|
||
[DllImport(Libraries.CryptoNative)] | ||
internal static extern void SslCtxSetClientCAList(SafeSslContextHandle ctx, SafeX509NameStackHandle x509NameStackPtr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Common/src/Interop/Unix/libssl/Interop.X509ChannelBindingHash.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Security.Cryptography; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class OpenSsl | ||
{ | ||
internal static HashAlgorithm GetHashForChannelBinding(X509Certificate2 cert) | ||
{ | ||
Oid signatureAlgorithm = cert.SignatureAlgorithm; | ||
switch (signatureAlgorithm.Value) | ||
{ | ||
// RFC 5929 4.1 says that MD5 and SHA1 both upgrade to EvpSha256 for cbt calculation | ||
case "1.2.840.113549.2.5": // MD5 | ||
case "1.2.840.113549.1.1.4": // MD5RSA | ||
case "1.3.14.3.2.26": // SHA1 | ||
case "1.2.840.10040.4.3": // SHA1DSA | ||
case "1.2.840.10045.4.1": // SHA1ECDSA | ||
case "1.2.840.113549.1.1.5": // SHA1RSA | ||
case "2.16.840.1.101.3.4.2.1": // SHA256 | ||
case "1.2.840.10045.4.3.2": // SHA256ECDSA | ||
case "1.2.840.113549.1.1.11": // SHA256RSA | ||
return SHA256.Create(); | ||
|
||
case "2.16.840.1.101.3.4.2.2": // SHA384 | ||
case "1.2.840.10045.4.3.3": // SHA384ECDSA | ||
case "1.2.840.113549.1.1.12": // SHA384RSA | ||
return SHA384.Create(); | ||
|
||
case "2.16.840.1.101.3.4.2.3": // SHA512 | ||
case "1.2.840.10045.4.3.4": // SHA512ECDSA | ||
case "1.2.840.113549.1.1.13": // SHA512RSA | ||
return SHA512.Create(); | ||
|
||
default: | ||
throw new ArgumentException(signatureAlgorithm.Value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.