. 내 경우에는 루트 인증서 중 하나를 가져 오는 네트워크 연결이 시간 초과되는 경우가있었습니다. 그런 다음 앞으로 요청할 때 다시 작동합니다.
나는 다른 인증서의 유효성 검사에 영향을 미치지 않으면 서 오류에도 불구하고 작업에 관심이있는 특정 인증서를 보낼 수있는 사용자 지정 콜백을 작성했습니다. 아래는 내 코드입니다. 당신이 아마 말할 수 있듯이, 나는 안드로이드 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;
}
불행히도 나는 그것을 제어 할 수 없습니다. 그리고 Azure 에뮬레이터를 사용하지 않고 로컬에서 테스트 할 때 제대로 연결되어 작동합니다. Azure가 적절한 인증서를 찾을 수없는 권한 문제 인 것 같습니다. 나는 당신의 제안을 시도했는데, 정말 고마워했습니다. 그러나 문제 해결보다는 해결 방법이 많습니다. –