Tôi đang cố gửi APN từ C# bằng phương thức SslStream.AuthenticateAsClient
bằng cách chuyển IP máy chủ, SslProtocols.Tls
và X509Certificate2Collection
. Nhưng tôi nhận được một thông báo lỗi:APN không thành công với "Xác thực không thành công vì bên từ xa đã đóng luồng truyền tải"
Authentication failed because remote party has closed the transport stream
Tôi đã thử mọi giải pháp thảo luận ở đây nhưng không hoạt động. Xin vui lòng giúp dưới đây là mã
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;
Chứng chỉ ứng dụng khách có phải do Apple cấp không? – jww
bạn có làm việc này không? Tôi đang cố gắng làm điều tương tự ở đây, với cùng một lỗi chính xác;) –