클라이언트 인증서 인증을 사용하여 SSL을 통해 웹 서비스에 연결하는 .p12 파일을 제공했습니다. 나는 PHP에서 cURL을 사용하여 성공적으로 작업하고있다. 요청을 수행 할 때이 내가 사용하고있는 옵션이다 : 지금 C# 및 .NET을 사용하여 동일한 작업을 할 노력하고있어클라이언트 인증서 인증을 사용하여 웹 서비스에 연결
$headers = array(
'Method: POST',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "'.$action.'"',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_SSLCERT, $this->clientcert);
curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->clientcerttype);
curl_setopt($ch, CURLOPT_SSLKEY, $this->keyfile);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->keypassword);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
$response = curl_exec($ch);
을,하지만 난 오류가 "SSL에 대한 보안 채널을 설정할 수 없습니다 점점 계속/권위있는 TLS : '. "."
키를 찾는 데 문제가없는 것 같아서 트러스트 문제가없는 것 같습니다. 그래도 선상에 어딘가에 뭔가가 옳지 않습니다.
테스트 프로그램을 만들었으므로 기본 호출이 작동하는지 테스트 할 수 있습니다.
public void StartviaWSHttp()
{
var binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.NegotiateServiceCredential = false;
binding.Security.Message.ClientCredentialType = MessageCredentialType.None;
var baseAddress = new Uri("https://<host>:<port>/LineEndpoint1");
var endpointAddress = new EndpointAddress(baseAddress);
var client = new LinePortTypeClient(binding, endpointAddress);
client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySerialNumber, "00d48a233bf4b77523");
Debug.Assert(client.ClientCredentials.ClientCertificate.Certificate.SerialNumber.ToLower() == "00d48a233bf4b77523");
var header = new ctSoapHeaderMsg();
var response = new object();
client.Open();
var responseCode = client.PerformFunction(ref header, "0893411111", out response);
client.Close();
Console.WriteLine("Response Code :" + responseCode);
Console.WriteLine("Response :" + response);
}
현재 사용자의 개인/인증서에서 인증서를 볼 때 신뢰와 관련하여 문제를보고하지 않습니다. 인증서 정보에는 인증서가 다음 용도로 사용되었다는 내용이 나와 있습니다. 모든 발급 정책 및 모든 응용 프로그램 정책. 인증 경로에는 하나의 항목 만 있으며 인증서 상태에는 "이 인증서는 정상입니다"라는 메시지가 표시됩니다.
나는 문제가 무엇인지 놓치고 있습니다. PHP 호출에 대해 PEER 및 HOST 검증을 수행 한 이후로 신뢰 문제가있을 수 있습니다. C#의 옵션인지 확실하지 않습니다.
업데이트 : (2013 8월 9일) 나는 System.Net 및 System.Net.Socket에 대한 몇 가지 자세한 추적을 설정합니다. 이것은 출력의 시작입니다.
System.Net Verbose: 0 : [16124] WebRequest::Create(https://dsl-wholesale-testing.iinet.net.au:50500/LineEndpoint1)
System.Net Verbose: 0 : [16124] HttpWebRequest#58508234::HttpWebRequest(https://dsl-wholesale-testing.iinet.net.au:50500/LineEndpoint1#128335743)
System.Net Information: 0 : [16124] Current OS installation type is 'Client'.
System.Net Information: 0 : [16124] RAS supported: True
System.Net Verbose: 0 : [16124] Exiting HttpWebRequest#58508234::HttpWebRequest()
System.Net Verbose: 0 : [16124] Exiting WebRequest::Create() -> HttpWebRequest#58508234
System.Net Verbose: 0 : [16124] ServicePoint#36898364::ServicePoint(dsl-wholesale-testing.iinet.net.au:50500)
System.Net Information: 0 : [16124] Associating HttpWebRequest#58508234 with ServicePoint#36898364
System.Net Verbose: 0 : [16124] HttpWebRequest#58508234::GetRequestStream()
System.Net Information: 0 : [16124] Associating Connection#47995487 with HttpWebRequest#58508234
System.Net.Sockets Verbose: 0 : [16124] Socket#31002555::Socket(AddressFamily#2)
System.Net.Sockets Verbose: 0 : [16124] Exiting Socket#31002555::Socket()
System.Net.Sockets Verbose: 0 : [16124] Socket#6243847::Socket(AddressFamily#23)
System.Net.Sockets Verbose: 0 : [16124] Exiting Socket#6243847::Socket()
System.Net.Sockets Verbose: 0 : [16124] DNS::TryInternalResolve(dsl-wholesale-testing.iinet.net.au)
System.Net.Sockets Verbose: 0 : [16124] Socket#31002555::Connect(203.173.51.130:50500#-2110560113)
System.Net.Sockets Information: 0 : [16124] Socket#31002555 - Created connection from 192.168.190.202:55397 to 203.173.51.130:50500.
System.Net.Sockets Verbose: 0 : [16124] Exiting Socket#31002555::Connect()
System.Net.Sockets Verbose: 0 : [16124] Socket#6243847::Close()
System.Net.Sockets Verbose: 0 : [16124] Socket#6243847::Dispose()
System.Net.Sockets Verbose: 0 : [16124] Exiting Socket#6243847::Close()
System.Net Information: 0 : [16124] Connection#47995487 - Created connection from 192.168.190.202:55397 to 203.173.51.130:50500.
System.Net Information: 0 : [16124] TlsStream#29695768::.ctor(host=dsl-wholesale-testing.iinet.net.au, #certs=0)
System.Net Information: 0 : [16124] Associating HttpWebRequest#58508234 with ConnectStream#25001628
System.Net Verbose: 0 : [16124] Exiting HttpWebRequest#58508234::GetRequestStream() -> ConnectStream#25001628
System.Net Verbose: 0 : [16124] ConnectStream#25001628::Write()
System.Net Verbose: 0 : [16124] Data from ConnectStream#25001628::Write
System.Net Verbose: 0 : [16124] (printing 1024 out of 1206)
System.Net Verbose: 0 : [16124] 00000000 : 3C 73 3A 45 6E 76 65 6C-6F 70 65 20 78 6D 6C 6E : <s:Envelope xmln
System.Net Information: 0 : [16124] TlsStream#29695768::.ctor(host=dsl-wholesale-testing.iinet.net.au, #certs=0)
더 인증서 나는 client.ClientCredentials.ClientCertificate에 인증서를 첨부했습니다에도 불구하고, 사용 집어 없지만, 내가 이런 일이나 방법을 왜 모르겠어요되었음을 시사 라인 그것을 붙이십시오. 인증서의 속성이 연결 대상인 호스트 이름과 일치해야합니까?
흥미 롭습니다. 나는 똑같은 코드와 똑같은 오류를 얻고 있으며 추적에서 동일한 TLS 인증서 # 0을 얻고 있지만 서버가 TLS 1.2를 지원한다는 것을 확실히 알고 있습니다. 나는 나의 지혜 끝에있다. – ajeh
System.Net.ServicePointManager.SecurityProtocol은 플래그이므로 비트 OR을 통해 추가 SecurityProtocolTypes를 지정할 수 있습니다. Ssl13 만 있으면 Tls는 무시됩니다 (PHP Curl이 아니라 C# 코드를 언급한다고 가정). – Reuben
웹 서비스 바인딩의 보안 요소에 누락 된 추가 요소 인 "이 필요했습니다. 그것을 추가하고 모든 것이 효과가있었습니다. –
ajeh