как я могу проверить сертификаты ssl в командной строке?

<p>я пытаюсь проверить/подтвердить, что ключ rsa, ca-bundle и сертификат, хранящиеся здесь, в порядке. они не обслуживаются веб-сервером. как я могу их проверить?</p>

<p>предполагая, что ваши сертификаты в формате pem, вы можете сделать:</p><pre><code>openssl verify cert.pem </code></pre><p>если ваш "ca-bundle" является файлом, содержащим дополнительные промежуточные сертификаты в формате pem:</p><pre><code>openssl verify -untrusted ca-bundle cert.pem </code></pre><p>если ваш openssl не настроен на автоматическое использование установленного набора корневых сертификатов (например, в <code>/etc/ssl/certs</code>), тогда вы можете использовать <code>-capath</code> или <code>-cafile</code> чтобы указать ca.</p>

<p>вот одна строка для проверки цепочки сертификатов:</p><pre><code>openssl verify -verbose -x509\_strict -cafile ca.pem -capath nosuchdir cert\_chain.pem </code></pre><p>это не требует установки ca в любом месте.</p><p>см. <a href="https://stackoverflow.com/questions/20409534/how-does-an-ssl-certificate-chain-bundle-work">https://stackoverflow.com/questions/20409534/how-does-an-ssl-certificate-chain-bundle-work</a> для получения подробной информации.</p>

<p>расширяя приведенные выше ответы.</p><p>если у вас есть промежуточные сертификаты в отдельном файле, так как они находятся в постфиксе и apache, чтобы назвать некоторые из них, вы все равно можете проверить цепочку в командной строке.</p><p>bash</p><pre><code>openssl verify -verbose -x509\_strict <(cat intermediate.crt my-domain.crt) </code></pre><p>большинство * nix снарядов</p><pre><code>cat intermediate.crt my-domain.crt | openssl verify -verbose -x509\_strict </code></pre><p>надеюсь, это может кому-нибудь помочь.</p>

<p>недавно я использовал этот инструмент <a href="https://github.com/drwetter/testssl.sh">https://github.com/drwetter/testssl.sh</a> , и он предоставляет подробный отчет, связанный с ssl.</p><p>пример вывода:</p><pre><code>testing protocols via sockets except npn+alpn sslv2 not offered (ok) sslv3 not offered (ok) tls 1 not offered tls 1.1 not offered tls 1.2 offered (ok) tls 1.3 not offered and downgraded to a weaker protocol npn/spdy not offered alpn/http2 h2, http/1.1 (offered) testing cipher categories null ciphers (no encryption) not offered (ok) anonymous null ciphers (no authentication) not offered (ok) export ciphers (w/o adh+null) not offered (ok) low: 64 bit + des, rc[2,4], md5 (w/o export) not offered (ok) triple des ciphers / idea not offered obsolete: seed + 128+256 bit cbc cipher offered non-fs strong encryption (aead ciphers) offered (ok) forward secure strong encryption (aead ciphers) offered (ok) testing robust (perfect) forward secrecy, (p)fs -- omitting null authentication/encryption, 3des, rc4 pfs is offered (ok) ecdhe-rsa-aes256-gcm-sha384 ecdhe-rsa-aes256-sha384 ecdhe-rsa-aes256-sha ecdhe-rsa-aes128-gcm-sha256 ecdhe-rsa-aes128-sha256 ecdhe-rsa-aes128-sha elliptic curves offered: prime256v1 secp384r1 secp521r1 x25519 x448 testing server preferences has server cipher order? yes (ok) negotiated protocol tlsv1.2 negotiated cipher ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) cipher order tlsv1.2: ecdhe-rsa-aes128-gcm-sha256 ecdhe-rsa-aes256-gcm-sha384 ecdhe-rsa-aes128-sha256 ecdhe-rsa-aes256-sha384 ecdhe-rsa-aes128-sha ecdhe-rsa-aes256-sha aes128-gcm-sha256 aes128-sha aes256-sha testing server defaults (server hello) tls extensions (standard) "renegotiation info/#65281" "server name/#0" "ec point formats/#11" "session ticket/#35" "status request/#5" "max fragment length/#1" "application layer protocol negotiation/#16" "encrypt-then-mac/#22" "extended master secret/#23" session ticket rfc 5077 hint 7200 seconds, session tickets keys seems to be rotated < daily ssl session id support yes session resumption tickets: yes, id: yes tls clock skew random values, no fingerprinting possible signature algorithm sha256 with rsa server key size rsa 2048 bits server key usage digital signature, key encipherment server extended key usage tls web server authentication, tls web client authentication serial / fingerprints redacted / sha1 redacted sha256 redacted common name (cn) redacted (cn in response to request w/o sni: *.redacted ) subjectaltname (san) redacted issuer let's encrypt authority x3 (let's encrypt from us) trust (hostname) ok via san (sni mandatory) chain of trust ok ev cert (experimental) no ets/"etls", visibility info not present certificate validity (utc) 72 >= 30 days (2020-03-19 22:41 --> 2020-06-17 22:41) # of certificates provided 2 certificate revocation list -- ocsp uri http://ocsp.int-x3.letsencrypt.org ocsp stapling offered, not revoked ocsp must staple extension -- dns caa rr (experimental) not offered certificate transparency yes (certificate extension) testing http header response @ "/" http status code 200 ok http clock skew -1 sec from localtime strict transport security 366 days=31622400 s, just this domain public key pinning -- server banner nginx application banner -- cookie(s) (none issued at "/") security headers x-frame-options sameorigin x-content-type-options nosniff x-served-by redacted, redacted cache-control public, max-age=3600 reverse proxy banner x-cache: hit, hit x-cache-hits: 3, 1 via: 1.1 varnish testing vulnerabilities heartbleed (cve-2014-0160) not vulnerable (ok), no heartbeat extension ccs (cve-2014-0224) not vulnerable (ok) ticketbleed (cve-2016-9244), experiment. not vulnerable (ok) robot not vulnerable (ok) secure renegotiation (rfc 5746) supported (ok) secure client-initiated renegotiation not vulnerable (ok) crime, tls (cve-2012-4929) not vulnerable (ok) breach (cve-2013-3587) potentially not ok, uses gzip http compression. - only supplied "/" tested can be ignored for static pages or if no secrets in the page poodle, ssl (cve-2014-3566) not vulnerable (ok), no sslv3 support tls\_fallback\_scsv (rfc 7507) no fallback possible (ok), no protocol below tls 1.2 offered sweet32 (cve-2016-2183, cve-2016-6329) not vulnerable (ok) freak (cve-2015-0204) not vulnerable (ok) drown (cve-2016-0800, cve-2016-0703) not vulnerable on this host and port (ok) make sure you don't use this certificate elsewhere with sslv2 enabled services https://censys.io/ipv4?q=redacted could help you to find out logjam (cve-2015-4000), experimental not vulnerable (ok): no dh export ciphers, no dh key detected with <= tls 1.2 beast (cve-2011-3389) not vulnerable (ok), no ssl3 or tls1 lucky13 (cve-2013-0169), experimental potentially vulnerable, uses cipher block chaining (cbc) ciphers with tls. check patches rc4 (cve-2013-2566, cve-2015-2808) no rc4 ciphers detected (ok) testing 370 ciphers via openssl plus sockets against the server, ordered by encryption strength hexcode cipher suite name (openssl) keyexch. encryption bits cipher suite name (iana/rfc) ----------------------------------------------------------------------------------------------------------------------------- xc030 ecdhe-rsa-aes256-gcm-sha384 ecdh 256 aesgcm 256 tls\_ecdhe\_rsa\_with\_aes\_256\_gcm\_sha384 xc028 ecdhe-rsa-aes256-sha384 ecdh 256 aes 256 tls\_ecdhe\_rsa\_with\_aes\_256\_cbc\_sha384 xc014 ecdhe-rsa-aes256-sha ecdh 256 aes 256 tls\_ecdhe\_rsa\_with\_aes\_256\_cbc\_sha x35 aes256-sha rsa aes 256 tls\_rsa\_with\_aes\_256\_cbc\_sha xc02f ecdhe-rsa-aes128-gcm-sha256 ecdh 256 aesgcm 128 tls\_ecdhe\_rsa\_with\_aes\_128\_gcm\_sha256 xc027 ecdhe-rsa-aes128-sha256 ecdh 256 aes 128 tls\_ecdhe\_rsa\_with\_aes\_128\_cbc\_sha256 xc013 ecdhe-rsa-aes128-sha ecdh 256 aes 128 tls\_ecdhe\_rsa\_with\_aes\_128\_cbc\_sha x9c aes128-gcm-sha256 rsa aesgcm 128 tls\_rsa\_with\_aes\_128\_gcm\_sha256 x2f aes128-sha rsa aes 128 tls\_rsa\_with\_aes\_128\_cbc\_sha running client simulations (http) via sockets android 4.4.2 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) android 5.0.0 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) android 6.0 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) android 7.0 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) android 8.1 (native) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) android 9.0 (native) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) android 10.0 (native) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) chrome 74 (win 10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) chrome 79 (win 10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) firefox 66 (win 8.1/10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) firefox 71 (win 10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) ie 6 xp no connection ie 8 win 7 no connection ie 8 xp no connection ie 11 win 7 tlsv1.2 ecdhe-rsa-aes128-sha256, 256 bit ecdh (p-256) ie 11 win 8.1 tlsv1.2 ecdhe-rsa-aes128-sha256, 256 bit ecdh (p-256) ie 11 win phone 8.1 tlsv1.2 ecdhe-rsa-aes128-sha256, 256 bit ecdh (p-256) ie 11 win 10 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) edge 15 win 10 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) edge 17 (win 10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) opera 66 (win 10) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) safari 9 ios 9 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) safari 9 os x 10.11 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) safari 10 os x 10.12 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) safari 12.1 (ios 12.2) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) safari 13.0 (macos 10.14.6) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) apple ats 9 ios 9 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) java 6u45 no connection java 7u25 no connection java 8u161 tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) java 11.0.2 (openjdk) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) java 12.0.1 (openjdk) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) openssl 1.0.2e tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 256 bit ecdh (p-256) openssl 1.1.0l (debian) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) openssl 1.1.1d (debian) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) thunderbird (68.3) tlsv1.2 ecdhe-rsa-aes128-gcm-sha256, 253 bit ecdh (x25519) </code></pre><p>еще один крутой инструмент cli - <code>gnutls-cli</code>. он встроен в системы macos и linux-unix.</p>