2012-04-05 2 views
2

나는 SSL 보안 외부 웹 서비스에 연결해야하는 Azure 웹 역할이 있습니다. 응용 프로그램이 웹 서비스에 연결을 시도 할 때 오류를주고 :Azure에서 HTTPS 웹 서비스에 연결

Could not establish trust relationship for the SSL/TLS secure channel with authority 'certname.organization.org'.

이 서비스 인증서로 푸른에 업로드 된 필요하지만 어떤 이유로 제대로 될 것 같지 않습니다 인증서 그것을 참조하거나 사용하는 것.

이 문제를 해결하는 방법에 대한 의견이 있으십니까?

답변

1

Azure의 서비스 클라이언트처럼 들리는데 외부 서비스의 SSL 인증서가 만족스럽지 않습니다. 서비스를 제어 할 수 있습니까?

당신은 푸른에 클라이언트에서 SSL 오류를 무시하려면 다음을 사용하여이를 테스트 할 수 있습니다 : 나는 간헐적으로뿐만 아니라이 문제를 본 적이

ServicePointManager.ServerCertificateValidationCallback = 
    (obj, certificate, chain, errors) => true; 
+0

불행히도 나는 그것을 제어 할 수 없습니다. 그리고 Azure 에뮬레이터를 사용하지 않고 로컬에서 테스트 할 때 제대로 연결되어 작동합니다. Azure가 적절한 인증서를 찾을 수없는 권한 문제 인 것 같습니다. 나는 당신의 제안을 시도했는데, 정말 고마워했습니다. 그러나 문제 해결보다는 해결 방법이 많습니다. –

1

. 내 경우에는 루트 인증서 중 하나를 가져 오는 네트워크 연결이 시간 초과되는 경우가있었습니다. 그런 다음 앞으로 요청할 때 다시 작동합니다.

나는 다른 인증서의 유효성 검사에 영향을 미치지 않으면 서 오류에도 불구하고 작업에 관심이있는 특정 인증서를 보낼 수있는 사용자 지정 콜백을 작성했습니다. 아래는 내 코드입니다. 당신이 아마 말할 수 있듯이, 나는 안드로이드 Cloud-to-Device Messaging 엔드 포인트를 치려고 노력하고 있으며, 구글이 사용하는 와일드 카드 인증서 문제를 해결하려고 노력하고 있지만 일반화가 가능해야한다. 이것은 또한 특정 오류를 진단하는 데 사용한 모든 로깅을 포함합니다. 인증서의 유효성을 확인하지 않으려는 경우에도 로깅 코드를 사용하여 진행 방법을 결정할 수 있습니다.

private static readonly Uri PUSH_URI = new Uri("https://android.apis.google.com/c2dm/send", UriKind.Absolute); 

/** 
//The following function needs to be wired up in code somewhere else, like this: 
ServicePointManager.ServerCertificateValidationCallback += ValidateDodgyGoogleCertificate; 
**/ 
/// <summary> 
/// Validates the SSL server certificate. Note this is process-wide code. 
/// Wrote a custom one because the certificate used for Google's push endpoint is not for the correct domain. Go Google. 
/// </summary> 
/// <param name="sender">either a host name string, or an object derived from WebRequest</param> 
/// <param name="cert">The certificate used to authenticate the remote party.</param> 
/// <param name="chain">The chain of certificate authorities associated with the remote certificate.</param> 
/// <param name="sslPolicyErrors">One or more errors associated with the remote certificate.</param> 
/// <returns> 
/// Returns a boolean value that determines whether the specified 
/// certificate is accepted for authentication; true to accept or false to 
/// reject. 
/// </returns> 
private static bool ValidateDodgyGoogleCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
{ 
    if (sslPolicyErrors == SslPolicyErrors.None) 
    { 
    // Good certificate. 
    return true; 
    } 

    string hostName = sender as string; 
    if (hostName == null) 
    { 
    WebRequest senderRequest = sender as WebRequest; 
    if (senderRequest != null) 
    { 
     hostName = senderRequest.RequestUri.Host; 
    } 
    } 

    //We want to get past the Google name mismatch, but not allow any other errors 
    if (sslPolicyErrors != SslPolicyErrors.RemoteCertificateNameMismatch) 
    { 
    StringBuilder sb = new StringBuilder(); 
    sb.AppendFormat("Rejecting remote server SSL certificate from host \"{0}\" issued to Subject \"{1}\" due to errors: {2}", hostName, cert.Subject, sslPolicyErrors); 

    if ((sslPolicyErrors | SslPolicyErrors.RemoteCertificateChainErrors) != SslPolicyErrors.None) 
    { 
     sb.AppendLine(); 
     sb.AppendLine("Chain status errors:"); 

     foreach (var chainStatusItem in chain.ChainStatus) 
     { 
     sb.AppendFormat("Chain Item Status: {0} StatusInfo: {1}", chainStatusItem.Status, chainStatusItem.StatusInformation); 
     sb.AppendLine(); 
     } 
    } 

    log.Info(sb.ToString()); 

    return false; 
    } 

    if (PUSH_URI.Host.Equals(hostName, StringComparison.InvariantCultureIgnoreCase)) 
    { 
    return true; 
    } 

    log.Info("Rejecting remote server SSL certificate from host \"{0}\" issued to Subject \"{1}\" due to errors: {2}", hostName, cert.Subject, sslPolicyErrors); 
    return false; 
} 
0

SSL 오류를 무시하면 할 수있는 한 가지 작업입니다.

그러나 컴퓨터에서 작동하고 인스턴스에서 작동하지 않는 경우 인증서 체인이 인스턴스에서 불완전한 것일 수도 있습니다. 컴퓨터에서 인증서를 열어야합니다. 인증 경로으로 이동하여 경로의 각 인증서를 내 보냅니다. 그런 다음

, 당신의 프로젝트에이 인증서를 추가하고 (.bat 인 또는 .cmd 파일) 시작 작업이 신뢰할 수있는 루트 CA에 추가 :

REM Install certificates. 
certutil -addstore -enterprise -f -v root Startup\Certificates\someROOTca.cer 
certutil -addstore -enterprise -f -v root Startup\Certificates\otherROOTca.cer 
+0

불행히도 이것이 Azure이므로 명령 줄에서 아무 것도 실행할 수 없지만 체인에서 인증서를 분리하라는 제안을 시도 할 것입니다. –

+0

사실, 시작 작업을 사용하여 실행할 수 있습니다. http://blog.smarx.com/posts/windows-azure-startup-tasks-tips-tricks-and-gotchas –

0

난 내 프로젝트의 루트에 CER 추가 "Copy Always"를 선택하고 다음 명령을 사용하여 Azure가 SSL 자체 서명으로 서버에 연결하도록하십시오.

REM Install certificates. 
certutil -addstore -enterprise -f -v root startsodev.cer 
관련 문제