使用代理的openssl s_客户端

使用代理的openssl s_客户端,openssl,Openssl,当您想要检查服务器的证书及其证书链时,这是一个很好的命令 当您使用HTTP/HTTPS代理时,有没有办法运行此命令?官方没有 但这里有一个补丁:您可以使用: 然后你可以这样做: proxytunnel -p yourproxy:8080 -d www.google.com:443 -a 7000 希望这能帮助你 对于2015年5月后来到这里的人:有一个新的“-proxy”选项将包含在openssl的下一个版本中:自openssl v1.1.0以来 openssl s_client -conne

当您想要检查服务器的证书及其证书链时,这是一个很好的命令

当您使用HTTP/HTTPS代理时,有没有办法运行此命令?

官方没有

但这里有一个补丁:

您可以使用:

然后你可以这样做:

proxytunnel -p yourproxy:8080 -d www.google.com:443 -a 7000

希望这能帮助你

对于2015年5月后来到这里的人:有一个新的“-proxy”选项将包含在openssl的下一个版本中:

自openssl v1.1.0以来

openssl s_client -connect localhost:7000 -showcerts

即使使用openssl v1.1.0,我在传递代理时也遇到了一些问题,例如
s_客户端:HTTP连接失败:400个错误请求
这迫使我编写了一个最小的Java类来显示SSL握手

C:\openssl>openssl version
OpenSSL 1.1.0g  2 Nov 2017
C:\openssl>openssl s_client -proxy 192.168.103.115:3128 -connect www.google.com -CAfile C:\TEMP\internalCA.crt
CONNECTED(00000088)
depth=2 DC = com, DC = xxxx, CN = xxxx CA interne
verify return:1
depth=1 C = FR, L = CROIX, CN = svproxysg1, emailAddress = xxxx@xxxx.xx
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = www.google.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
   i:/C=xxxx/L=xxxx/CN=svproxysg1/emailAddress=xxxx@xxxx.xx
 1 s:/C=xxxx/L=xxxx/CN=svproxysg1/emailAddress=xxxx@xxxx.xx
   i:/DC=com/DC=xxxxx/CN=xxxxx CA interne
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDkTCCAnmgAwIBAgIJAIv4/hQAAAAAMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV
BAYTAkZSMQ4wDAYDVQQHEwVDUk9JWDETMBEGA1UEAxMKc3Zwcm94eXNnMTEeMBwG
具有以下依赖关系:

    public static void main(String[] args) throws IOException, URISyntaxException {
    HttpHost proxy = new HttpHost("proxy.my.company", 8080);
    DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
    CloseableHttpClient httpclient = HttpClients.custom()
            .setRoutePlanner(routePlanner)
            .build();
    URI uri = new URIBuilder()
            .setScheme("https")
            .setHost("www.myhost.com")
            .build();
    HttpGet httpget = new HttpGet(uri);
    httpclient.execute(httpget);
}

事实上,截至2015年5月22日,该补丁已实际实施。我还看到,我在2016年3月1日刚刚尝试了OpenSSL 1.0.2g(Windows),但它对代理选项一无所知。为什么?是否可以将openssl包更新为不与操作系统捆绑的版本?@ChristianSchäfer这是因为1.0.2xx版不是“下一版本”。此选项仅在OpenSSL 1.1.0xx及更高版本中可用。事实上,请参阅手册页,我必须在后台运行
proxytunnel-p yourproxy:8080-d www.google.com:443-a 7000
以释放终端以执行第二个命令。
proxytunnel
支持代理身份验证,而(afaict)
OpenSSL s_client-proxy
不支持代理身份验证,至少不在1.1.0h中。下载了1.1.1源代码,尝试了此语法。工作得很好。Cheers.thanks,我没有注意到<代码>代理> /Cord>选项,但是我想知道,如果不是它,它应该考虑代理Evvar。劳尔,我没有在源代码中找到“HTTPJOXY代理”,所以我可以认为代理环境变量不被支持。
    public static void main(String[] args) throws IOException, URISyntaxException {
    HttpHost proxy = new HttpHost("proxy.my.company", 8080);
    DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
    CloseableHttpClient httpclient = HttpClients.custom()
            .setRoutePlanner(routePlanner)
            .build();
    URI uri = new URIBuilder()
            .setScheme("https")
            .setHost("www.myhost.com")
            .build();
    HttpGet httpget = new HttpGet(uri);
    httpclient.execute(httpget);
}
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
        <type>jar</type>
    </dependency>
trustStore provider is :
init truststore
adding as trusted cert:
  Subject: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
  Issuer:  CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
  Algorithm: RSA; Serial number: 0xc3517
  Valid from Mon Jun 21 06:00:00 CEST 1999 until Mon Jun 22 06:00:00 CEST 2020

adding as trusted cert:
  Subject: CN=SecureTrust CA, O=SecureTrust Corporation, C=US
  Issuer:  CN=SecureTrust CA, O=SecureTrust Corporation, C=US
(....)