Parse and display human-readable details from X.509 PEM certificates using openssl.
-----BEGIN CERTIFICATE-----) pasted directly, OR.pem or .crt file, ORexample.com)Write the PEM content to a temp file, then:
```
echo "PEM_CONTENT" | openssl x509 -text -noout
```
Or use process substitution if available.
```
openssl x509 -text -noout -in /path/to/cert.pem
```
```
echo | openssl s_client -connect HOSTNAME:443 -servername HOSTNAME 2>/dev/null | openssl x509 -text -noout
```
openssl x509 -text output in a clean, readable format:Subject: lineIssuer: lineNot Before:Not After :Serial Number:X509v3 Subject Alternative Name: block for all DNS: and IP Address: entriesPublic Key Algorithm: and key size (e.g., RSA Public-Key: (2048 bit))Signature Algorithm:openssl is not found, tell the user: > "This skill requires openssl. Install with: brew install openssl (macOS) or sudo apt install openssl (Linux)."
From file:
Command: openssl x509 -text -noout -in /etc/ssl/cert.pem
From hostname:
Command: echo | openssl s_client -connect github.com:443 -servername github.com 2>/dev/null | openssl x509 -text -noout
Sample parsed output:
Subject: CN=github.com, O=GitHub, Inc., C=US
Issuer: CN=DigiCert TLS Hybrid ECC SHA384 2020 CA1, O=DigiCert Inc, C=US
Valid From: 2024-03-07
Valid Until: 2025-03-06 ⚠ Expires in 14 days
Serial: 0a:bc:12:...
SANs: github.com, www.github.com
Key: EC 256-bit (prime256v1)
Signature: ecdsa-with-SHA384
openssl not found → tell user to install itunable to load certificate; tell user the input does not appear to be a valid PEM certificateopenssl s_client will fail; report connection error and suggest checking the hostname or networkopenssl x509 -inform DER -in cert.der -out cert.pem共 1 个版本