1

PushSharp를 사용하여 앱에 푸시 알림을 보내려고합니다. 두 개의 Apple 계정이 있습니다. 하나는 일반 계정이고 다른 하나는 Enterprise 계정입니다. 정상적인 계정에 개발자 인증서가 있지만 내 개발 및 배포 인증서가 모두 Enterprise 계정에서 작동하지 않습니다. 나는 인증 예외를 얻을 ..iOS 푸시 알림 AuthenticationException

A call to SSPI failed, see inner exception. 

Inner Exception: 
[System.ComponentModel.Win32Exception]: {"An unknown error occurred while processing the certificate"} 

이 (I 아웃 라인을 언급하지 않았다) PushSharp의 코드에서 발생 여기

try 
{ 
    stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, System.Security.Authentication.SslProtocols.Ssl3, false); 
    //stream.AuthenticateAsClient(this.appleSettings.Host); 
} 
catch (System.Security.Authentication.AuthenticationException ex) 
{ 
    throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex); 
} 

내 테스트 프로젝트에서 코드입니다 :

public static void SendPingToApple() 
{ 
    try 
    { 
     var devicetoken = "mytoken"; 
     var appleCert = File.ReadAllBytes(AssemblyPathName + @"\Resources\DistPrivKey1.p12"); 
     var push = new PushBroker(); 
     push.RegisterAppleService(new ApplePushChannelSettings(IsProduction, appleCert, "password")); 

     push.QueueNotification(new AppleNotification() 
      .ForDeviceToken(devicetoken.ToUpper()) 
      .WithAlert("Test Notification")); 

      push.StopAllServices(); 
    } 
    catch (Exception ex) 
    { 
     throw; 
    } 
} 
+0

openssl을 사용하여 엔터프라이즈 인증서를 사용하여 apns 서비스에 연결하려고 했습니까? 먼저 인증서에 문제가 없는지 확인하십시오. – Nilesh

+0

아니요? 그것을하는 방법이 나에게 즉시 명백하지 않습니다. 당신은 정교 할 수 있습니까? –

+0

다음 명령을 실행해야합니다. openssl s_client -connect gateway.sandbox.push.apple.com:2195 -Cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile "Entrust.net 인증 기관 (2048) .pem"다음에 따라 URL을 업데이트하십시오. 어떤 인증서를 사용하고 있습니까? 연결에 실패하면 인증서 또는 네트워크 구성에 문제가 있습니다. – Nilesh

답변

1

다음 명령

openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem 

    openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem 
을 사용하여 PEM 형식으로 SSL 인증서를 변환

다음 명령을 실행하여 인증서 또는 네트워크 연결에 문제가 없는지 확인하십시오.

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile "Entrust.net Certification Authority (2048).pem"

Entrust 인증서를 다운로드하고 APNS 인증서가 Entrust에 의해 서명되어 있으므로 pem으로 변환해야합니다.

+0

OK @Nilesh. APNS 인증서를 사용하고 있다고 생각하지 않습니다. 나는 하나를 생성하고 Entrust certficate (.cer.txt로 다운로드 한)를 다운로드했으나 작동시키지 못했습니다. 올바른 개인 키를 사용하고 있는지 확실하지 않습니다 (APNS 인증서의 개인 키를 가져올 위치가 확실하지 않습니다). –

+0

도움 Nilesh 주셔서 감사합니다. 귀하의 답변에 제 인증서가 유효하지 않은 것으로 나타났습니다. 어떤 이유로 APNS 인증서에 대한 새로운 CSR을 생성해야했습니다. 그렇지 않으면 APNS 인증서에 키 체인에 연관된 키가 없습니다. PushSharp에 대한 p12 내보내기 및 내보내기 작업이 이루어졌습니다. –

+0

다행히 도움 : – Nilesh