我试图在iOS 6教程:第1/2部分中运行Apple推送通知服务中的Ray Wenderlich教程.
我在本地目录中创建了AppID和SSL证书以及密钥和PEM文件.之后,我到了测试证书是否有效的步骤,我从这个本地目录调用了以下命令:
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195
-cert PushChatCert.pem -key PushChatKey.pem
Run Code Online (Sandbox Code Playgroud)
这产生了很多输出.在输出的中间是以下内容:
verify error:num=20:unable to get local issuer certificate
verify return:0
Run Code Online (Sandbox Code Playgroud)
这是一个错误,还是一个错误的测试?如果是错误,原因是什么或者您建议解决什么?
这是完整的输出(减去证书数据):
Enter pass phrase for PushChatKey.pem:
CONNECTED(00000003)
depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=iTMS Engineering/CN=gateway.sandbox.push.apple.com
i:/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
1 s:/C=US/O=Entrust, …Run Code Online (Sandbox Code Playgroud) 我在使用 http 客户端的自定义证书进行 HTTP 调用时遇到问题。例子:
try
{
var handler = new HttpClientHandler();
//download certificate from https://api.alfabank.ru/sites/api.alfabank.ru/files/u1/apidevelopers.cert.pem
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "apidevelopers.cert.pem");
handler.ClientCertificates.Add(new X509Certificate2(path));
using (var httpClient = new HttpClient(handler))
{
var response =
await httpClient.GetAsync(
"https://apiws.alfabank.ru");
Console.WriteLine(response.StatusCode);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
Console.WriteLine(ex.InnerException.StackTrace);
}
}
Run Code Online (Sandbox Code Playgroud)
发生的错误是:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: Unexpected message received or incorrect …Run Code Online (Sandbox Code Playgroud)