.NET 응용 프로그램에서 협상 된 TLS 버전 결정
. 그러나 연결 설정 중에 사용되는 실제 TLS 버전은 다를 수 있습니다. 이 안내서는 협상 된 TLS 버전을 결정하는 두 가지 방법을 설명합니다.
메소드 1 : 반사
이 기술은 반사를 활용하여 내부 속성 및 필드에 액세스하여 SSL 프로토콜 버전을 얻습니다. 이것은 내부 API에 의존하며 향후 .NET 업데이트로 변경 될 수 있습니다.
using System.IO.Compression;
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
// ... other code ...
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls13;
// ... other code ...
Uri requestUri = new Uri("https://somesite.com");
var request = WebRequest.CreateHttp(requestUri);
// ... other code ...
using (var requestStream = request.GetRequestStream()) {
// Request stream validated; now extract SSL protocol
SslProtocols sslProtocol = ExtractSslProtocol(requestStream);
if (sslProtocol != SslProtocols.None) {
// Process the sslProtocol value
}
}
// ... ExtractSslProtocol function (implementation would be provided here) ...
메소드 2 : 보안 연결 컨텍스트 속성 (고급)
이 메소드는 secur32.dll
라이브러리를 통해 연결 컨텍스트 속성에 액세스합니다. 이 접근법은 비공개 핸들 및 구조를 사용하여 휴대용이 덜 휴대하고 더 복잡하게 만듭니다. (복잡성과 잠재적 불안정성으로 인해 세부 구현이 생략되었습니다.)
중요한 고려 사항 :
tcpclient
:
이 정보는 개발자가 .NET 응용 프로그램에서 사용하는 보안 프로토콜을 이해하고 관리하는 데 도움이됩니다. 반사 사용 및 관리되지 않는 라이브러리와의 상호 작용과 관련된 영향과 잠재적 위험을 신중하게 고려해야합니다. 부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3