1

我在开箱即用地连接到苹果的沙盒服务器时遇到了一些麻烦。我真的不知道这只是我的程序错误还是我的证书。

我们来看一下:

Using client As New TcpClient()
        client.Connect("gateway.sandbox.push.apple.com", 2195)
        Using networkStream As NetworkStream = client.GetStream()
            Console.WriteLine("Client connected.")

            Dim clientCertificate As New X509Certificate("certfile.p12", "PASS")
            Dim clientCertificateCollection As New X509CertificateCollection(New X509Certificate(0) {clientCertificate})

            ' Create an SSL stream that will close the client's stream.
            Dim sslStream As New SslStream(client.GetStream(), False, AddressOf ValidateServerCertificate, Nothing)

            Try
                sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Default, False)
            Catch ex As AuthenticationException
                Console.WriteLine("Exception: {0}", ex.Message)
                If ex.InnerException IsNot Nothing Then
                    Console.WriteLine("Inner exception: {0}", ex.InnerException.Message)
                End If
                Console.WriteLine("Authentication failed - closing the connection.")
                client.Close()
                Return
            End Try
        End Using
    End Using

我收到以下错误:“SSPI 调用失败”。

现在我的问题是,我必须在钥匙串中导出哪个证书?我的私钥、aps_provisioning、苹果开发证书还是我的开发者证书?

提前致谢!

4

0 回答 0