Languages
[Edit]
EN

Bash - download public *.pem certificate from https connection

8 points
Created by:
Payne
654

In this short article, we would like to show how to download public certificate from indicated domain that uses HTTPS protocol.

Run the following command:

openssl s_client -showcerts -connect some-domain.com:443 < /dev/null 2> /dev/null | openssl x509 -outform PEM > downloaded_cert.pem

Where:

  • openssl s_client -showcerts -connect some-domain.com:443 < /dev/null 2> /dev/null
    downloads certificate omitting occurred errors,
  • openssl x509 -outform PEM > downloaded_cert.pem
    converts certificate to *.pem format.

 

Practical example

This section shows how to get dirask.com cetificate.

Run following command:

openssl s_client -showcerts -connect dirask.com:443 < /dev/null 2> /dev/null | openssl x509 -outform PEM

Example output:

-----BEGIN CERTIFICATE-----
MIIFMzCCBNigAwIBAgIQDXAzMsR/+IffBk+JxoCTPzAKBggqhkjOPQQDAjBKMQsw
CQYDVQQGEwJVUzEZMBcGA1UEChMQQ2xvdWRmbGFyZSwgSW5jLjEgMB4GA1UEAxMX
Q2xvdWRmbGFyZSBJbmMgRUNDIENBLTMwHhcNMjEwNTEwMDAwMDAwWhcNMjIwNTA5
MjM1OTU5WjB1MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQG
A1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQQ2xvdWRmbGFyZSwgSW5jLjEe
MBwGA1UEAxMVc25pLmNsb3VkZmxhcmVzc2wuY29tMFkwEwYHKoZIzj0CAQYIKoZI
zj0DAQcDQgAEvf+BhNxEhoS9mypqUkAHtzX2LDiYTOpdmiDDr2W/gnZg4dbwoW3n
OkRm3GINZSaGUa4AVEYpzjXeNXM5nIcXdqOCA3MwggNvMB8GA1UdIwQYMBaAFKXO
N+rrsHUOlGeItEX62SQQh5YfMB0GA1UdDgQWBBQcyl0/1KZz4zPTQWkRoKaiAUCX
tDA6BgNVHREEMzAxghVzbmkuY2xvdWRmbGFyZXNzbC5jb22CCmRpcmFzay5jb22C
DCouZGlyYXNrLmNvbTAOBgNVHQ8BAf8EBAM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xm3sgERo
GjNx4gIhAMbk4RcBQy5Jn/bPLS0Xr8VmfKYOxGhOckzbxejOBePv
-----END CERTIFICATE-----

 

Alternative titles

  1. Bash - save remote server SSL certificate as locall file
  2. Bash - download public *.pem certificate for domain (https protocol)
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - download public *.pem certificate from https connection
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join