Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java等价于使用curl命令行实用程序调用带有证书的https url的rest调用_Java_Rest_Ssl_Curl_Ssl Certificate - Fatal编程技术网

Java等价于使用curl命令行实用程序调用带有证书的https url的rest调用

Java等价于使用curl命令行实用程序调用带有证书的https url的rest调用,java,rest,ssl,curl,ssl-certificate,Java,Rest,Ssl,Curl,Ssl Certificate,说到java,我有点不在行。所以,我需要所有能得到的帮助。 有没有办法让下面的功能在Java中正常工作 curl --cert public_cert.pem --key privateKeyNOPASS.key --cacert CAchain.pem https://abc.webapp.com 我想知道这是否可以在Java中使用现有的证书(命令中提到的证书)来完成 TIA是的,关于如何实现这一点,会有很多不同的例子,这取决于您是想只使用JDK还是愿意使用OkHttp这样的库。需要一些组件

说到java,我有点不在行。所以,我需要所有能得到的帮助。 有没有办法让下面的功能在Java中正常工作

curl --cert public_cert.pem --key privateKeyNOPASS.key --cacert CAchain.pem https://abc.webapp.com
我想知道这是否可以在Java中使用现有的证书(命令中提到的证书)来完成


TIA

是的,关于如何实现这一点,会有很多不同的例子,这取决于您是想只使用JDK还是愿意使用OkHttp这样的库。需要一些组件

下面是一个使用自定义CA证书和客户端身份验证的OkHttp单元测试

我有一个用于OSX的java+OkHttp客户端,它完全支持这一功能,因此您可以在那里选择代码,或者运行命令行在Mac上进行测试。n、 b.它假设您已使用JDK keytool将密钥加载到密钥库中

$ brew install yschimke/tap/oksocial
$ oksocial --help
        --cert <serverCerts>
            Use given server cert (Root CA) 
        --clientauth
            Use Client Authentication (from keystore)
        --keystore <keystoreFile>
            Keystore
$brew安装yschimke/tap/oksocial
$oksocial——帮助
--证书
使用给定的服务器证书(根CA)
--克利恩塔斯
使用客户端身份验证(来自密钥库)
--密钥库
密钥库
加载证书和构建OkHttpClient的大部分代码都在这里


如果您能在不使用自定义/开源libsI的情况下指导我实现,我将不胜感激。我真的没有时间这么做。对不起。我建议你自己去努力,找一些例子,当你发现一个障碍时,把它们作为一个新问题发布出来。当然。我会的。谢谢你的回复。
$ brew install yschimke/tap/oksocial
$ oksocial --help
        --cert <serverCerts>
            Use given server cert (Root CA) 
        --clientauth
            Use Client Authentication (from keystore)
        --keystore <keystoreFile>
            Keystore