6

Sto tentando di inviare APN da C# utilizzando il metodo SslStream.AuthenticateAsClient passando l'IP del server, SslProtocols.Tls e X509Certificate2Collection. Ma io sono sempre un messaggio di errore:Errore APN con "Autenticazione non riuscita perché il partecipante remoto ha chiuso il flusso di trasporto"

Authentication failed because remote party has closed the transport stream 

Ho provato ogni soluzione discusso qui, ma non funziona niente. Si prega di aiuto qui sotto è il codice

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

Il certificato client è stato emesso da Apple? – jww

+1

hai questo lavoro? Sto cercando di fare esattamente la stessa cosa qui, con lo stesso identico errore;) –

risposta

1

ho dovuto affrontare la stessa situazione dopo la disattivazione SSL3. Dopo aver generato un nuovo certificato, ha funzionato.