mac curl: (58) SSL: Can't load the certificate and its private key: OSStatus -25299 的解决方案

这是在 mac 下 curl 使用 pem 证书时发生的问题。原因是 iOS/macOS 的默认 SSL 实现 Secure Transport 在指定证书字符串时只允许使用系统或用户钥匙串(Keychain)中的名称或 PKCS#12 编码的证书和密钥。

另外,如果使用的是当前目录下的文件最好使用“./”前缀,避免与钥匙串中的别名冲突。

如何查看自己在使用的 curl 的情况呢,使用 curl --version

# curl with SecureTransport
$ curl --version
curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
# curl with OpenSSL
curl 7.53.1 (x86_64-apple-darwin16.4.0) libcurl/7.53.1 OpenSSL/1.0.2k zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy

可以明显看到两者的区别。

我们可以使用 Homebrew 来安装 curl with OpenSSL:

$ brew unlink curl
$ brew install curl --with-openssl
$ brew link curl --force

# 记得在环境变量 PATH 中将 /usr/local/bin 放于 /usr/bin 之前
$ which curl
/usr/local/bin/curl

相关资料:

转载于:https://my.oschina.net/tridays/blog/857872

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值