6

我試圖通過傳遞服務器IP,SslProtocols.TlsX509Certificate2Collection使用SslStream.AuthenticateAsClient方法從C#發送APN。但我收到錯誤消息:APN由於「驗證失敗,因爲遠程方已關閉傳輸流」

Authentication failed because remote party has closed the transport stream 

我試圖在這裏討論,但沒有工作的每一個解決方案。請在下面幫忙是

X509Certificate2Collection certs = new X509Certificate2Collection(); 

X509Certificate2 xcert = new X509Certificate2(); 
xcert.Import(@"D:\certify.p12", "password", X509KeyStorageFlags.UserKeySet); 


certs.Add(xcert); 

// Apple development server address 
string apsHost; 

if (xcert.ToString().Contains(ProductionKeyFriendName)) 
    apsHost = "gateway.push.apple.com"; 
else 
    apsHost = "gateway.sandbox.push.apple.com"; 

// Create a TCP socket connection to the Apple server on port 2195 

TcpClient tcpClient = new TcpClient(); 
tcpClient.Connect(apsHost, 2195); 

// Create a new SSL stream over the connection 
sslStream = new SslStream(tcpClient.GetStream()); 

// Authenticate using the Apple cert 

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 
sslStream.AuthenticateAsClient(apsHost, certs, System.Security.Authentication.SslProtocols.Tls, false); 

return true; 
+0

Apple是否頒發了客戶端證書? – jww

+1

你有這個工作嗎?我試圖在這裏做完全相同的事情,具有完全相同的錯誤;) –

回答

1

我面臨同樣的情況禁用SSL3後的代碼。生成新的證書後,它得到了工作。

相關問題