转自:https://curl.haxx.se/mail/archive-2005-09/0138.html

Greetings CURL users!

I just subscribed to the list and would like to share a problem and it's
solution, after a couple of hours working around it... I was going to write
to the list for help ;)

I was having problems using Curl to connect to a https server using a client
certificate. I believe i was doing everything by the book, but somehow Curl
kept complaining about the private key file.

1) I had a PKCS#12 file which contained the CA and Client certificates and
the private key: "MULTICERT.p12"

2) I convert it to PEM format with:
openssl pkcs12 -in MULTICERT.p12 -out cert.pem
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

and the file cert.pem was created with all the certificates and the private
key (i used "xxxxxx" for the PEM pass phrase).

3) However when i used Curl to connect to the https server

curl -d "var1=value1&var2=value2&..." -G -v --cert cert.pem:xxxxxx
https://www.somesite.com/page
* About to connect() to www.somesite.com port 443
* Trying 123.123.123.123... * connected
* Connected to www.somesite.com (123.123.123.123) port 443
* unable to set private key file: 'cert.pem' type PEM

* Closing connection #0
curl: (58) unable to set private key file: 'cert.pem' type PEM

4) So then i tried to put the CA certificate, Client Certificate and Private
Key in separate files:
openssl pkcs12 -in MULTICERT.p12 -out ca.pem -cacerts -nokeys
openssl pkcs12 -in MULTICERT.p12 -out client.pem -clcerts -nokeys
openssl pkcs12 -in MULTICERT.p12 -out key.pem -nocerts

and then i tried Curl again:

curl -d "var1=value1&var2=value2&..." -G -v --key key.pem --cacert
ca.pem --cert client.pem:xxxxxx https://www.somesite.com/page

and it worked!!! :)

Still don't know why the first method - having everything in one cert file -
didn't work...!?
Maybe the proivate key was'nt on the right order...

Well, anyway, hope this helps anyone

Cheers!

转载于:https://www.cnblogs.com/z1500592/p/10338180.html

curl-users unable to set private key file ?相关推荐

  1. unable to load client certificate private key file

    解决方法可以跳过看最后!!!o( ̄︶ ̄)o 终端执行 openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert MyPus ...

  2. unable to load Private Key 6572:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\

    1. 问题描述 在win系统下apache部署https的时候需要生成自签名证书(完整部署过程参考:https://www.cnblogs.com/hld123/p/6343437.html), 这时 ...

  3. Unable to use key file xxx (OpenSSH SSH-2 private key)

    Unable to use key file "xxx" (OpenSSH SSH-2 private key) When you try to use a private key ...

  4. Unable to use key file id_rsa (OpenSSH SSH-2 ...

    2019独角兽企业重金招聘Python工程师标准>>> 原因是openssh使用的私钥格式与putty使用的私钥格式不一样. 解决方法是下载putty软件系列的"putty ...

  5. Centos系列 Curl error (37): Couldn‘t read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-XXXX

    最近在Centos8系统安装gcc时提示"Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/ ...

  6. ORA-09925: Unable to create audit trail file 在DBCA时

    ORA-09925: Unable to create audit trail file 在DBCA时 ***数据库后,再执行dbca时候报错 ORA-09925: Unable to create ...

  7. 【原创】浅析密码学在互联网支付中的应用|RSA,Hash,AES,DES,3DES,SHA1,SHA256,MD5,SSL,Private Key,Public Key...

    一)概述 什么是互联网支付? 当支付遇到互联网,一场革命自然不可避免.成为现实的是传统的现金支付已经"退居二线",各种在线支付方式成为人们日常消费的主要支付方式.银行推出的网银以及 ...

  8. Generate public key from private key in keychain

    ref link: http://stackoverflow.com/questions/16847081/i-lost-my-public-key-can-i-recover-it-from-a-p ...

  9. RSA密钥BEGIN CERTIFICATE、BEGIN RSA PRIVATE KEY和BEGIN PRIVATE KEY的区别

    最近在用RSA做签名校验,遇到个坑,对方给的RSA密钥一直不能解析成PublicKey对象, 他们那边使用PHP可以直接使用,我这边是用java代码却用不了,百度相关的资料也很少, 后来才发现是RSA ...

最新文章

  1. 基于运算放大器的线性稳压器
  2. Ubuntu 14.04更新为国内阿里源解决apt-get install无法执行的问题
  3. Grinder搭建小记与Nduja(这次不待续了)
  4. [分享]iOS开发-实现view底部控件随着键盘的弹出而上移的效果
  5. React开发(274):ant design 时间显示秒
  6. LeetCode 1905. 统计子岛屿(BFS)
  7. python标识符、命名规则及关键字(含笔记)
  8. Hibernate怎么提升数据库查询的性能 (1)
  9. 相似度计算 java_Java基于余弦方法实现的计算相似度算法示例
  10. python编程可以自学么-风变编程的Python这么火,零基础可以自学吗?
  11. [恢]hdu 2138
  12. 如何在本地使用markdown进行博客编辑
  13. 【图频处理】基于matlab GUI界面环图像处理与音乐播放系统【含Matlab源码 185期】
  14. 开源免费制造业erp erp5的优点分析
  15. MT5和MT4交易软件有什么区别?
  16. DFS(深度优先遍历)
  17. 有没有视频合并软件?合并视频这样做
  18. 使用高德sdk时,提供SHA1
  19. 现代C语言程序设计之C语言概述
  20. ! LaTeX Error: File xxx.sty not found-统一解决办法

热门文章

  1. 2019计算机考证湖南考点
  2. mysql5.7.17_mysql-5.7.17的最新安装教程
  3. 计算机类综合素质测评考什么,考事业编的综合素质测试主要考什么?是什么样子的题型?...
  4. 利用java实现正弦函数的绘制_利用Excel中的Subtotal函数实现自动编号
  5. 付费就能查「你注册过哪些网站」,究竟是不是智商税?
  6. baidu网址提交|baidu收录网址提交|向百度提交网站
  7. 解析国外游戏建模《绝地求生》:炮塔楼制作细节过程
  8. ★专题0:py语法精讲:字典
  9. 转述稻盛和夫先生的“六项精进”
  10. 阿里云被工信部暂停合作!Log4j 持续爆雷,啥时候是个头?