我正在尝试在 C# 中查询 Apple 的反馈服务以获取设备列表。但它抛出:
未知异常:
System.ComponentModel.Win32Exception (0x80004005):处理证书时发生未知错误。
错误消息说:
对 SSPI 的调用失败,请参阅内部异常。
以下是我为与反馈服务进行通信而实现的代码片段。这类似于 PushSharp API:
X509Certificate2 certName = new
X509Certificate2(File.ReadAllBytes("CertificateFile.p12"));
X509Certificate2Collection certs = new X509Certificate2Collection(certName);
string hostName = "feedback.sandbox.push.apple.com";
TcpClient tcpClientF = new TcpClient(hostName, 2196)
SslStream sslStreamF = new SslStream(
tcpClientF.GetStream(),
true,
(sender, cert, chain, sslErrs) => { return true; },
(sender, targetHost, localCerts, remoteCert, acceptableIssuers) =>
{ return certName; });
sslStreamF.AuthenticateAsClient(hostName, certs, SslProtocols.Tls, false);
我在这里搜索了多个线程,但似乎没有解决我的问题。我已经验证了证书文件并且它是有效的。