@@ -40,15 +40,22 @@ $ keytool -printcert -rfc -sslserver google.com:443 > google.pem
40
40
41
41
# Show full cert chain (CN, SAN and Expiry) of TLS server
42
42
$ echo | openssl s_client -showcerts -connect google.com:443 2> /dev/null \
43
- | while openssl x509 -noout -subject -ext subjectAltName -issuer -dates -fingerprint 2> /dev/null; do echo " **************" ; done
43
+ | while openssl x509 -noout \
44
+ -subject -ext subjectAltName -issuer -dates \
45
+ -fingerprint -sha256 -serial 2> /dev/null; \
46
+ do echo " --------------" ; done
44
47
45
48
# Show just the cert details of a TLS server
46
49
$ echo | openssl s_client -showcerts -connect google.com:443 2> /dev/null \
47
50
| openssl x509 -inform pem -noout -text
48
51
49
52
# Show full cert chain of PEM
50
- $ cat cert.pem | while openssl x509 -noout -subject -ext subjectAltName -issuer -dates -fingerprint 2> /dev/null; do echo " **************" ; done
51
- $ keytool -printcert -file cert.pem | grep -i issuer
53
+ $ cat cert.pem | while openssl x509 -noout \
54
+ -subject -ext subjectAltName -issuer -dates \
55
+ -fingerprint -sha256 -serial 2> /dev/null; \
56
+ do echo " **************" ; done
57
+ $ keytool -printcert -file cert.pem \
58
+ | grep -i -e " Owner" -e " Issuer:" -e " Serial number:" -e " SHA256:"
52
59
53
60
# Extract TLS public keys in Cert pinning format
54
61
$ openssl s_client -connect ' dns.google.com:443' 2>&1 < /dev/null \
@@ -151,7 +158,8 @@ $ echo -ne $(cat cert.cer) | openssl rsa -check
151
158
$ while openssl x509 -noout -subject -issuer -dates; do echo ........... ; done < $( find -L /etc/ssl/certs -regex " .*/ca-\(bundle\|certificates\).crt" ) 2> /dev/null | grep -i subject
152
159
153
160
# Using java keytool
154
- $ keytool -printcert -file /etc/ssl/certs/ca-bundle.crt | grep -i issuer
161
+ $ keytool -printcert -file /etc/ssl/certs/ca-bundle.crt \
162
+ | grep -i -e " Owner" -e " Issuer:" -e " Serial number:" -e " SHA256:"
155
163
```
156
164
157
165
### OpenJDK
@@ -195,6 +203,15 @@ $ keytool -printcert -file /etc/ssl/certs/ca-bundle.crt | grep -i issuer
195
203
* [ OpenJDK CACerts] ( https://github.com/openjdk/jdk/tree/master/src/java.base/share/data/cacerts )
196
204
* [ Android CACerts] ( https://android.googlesource.com/platform/system/ca-certificates/+/master/files )
197
205
206
+
207
+ * ** Use Mac System truststore in Java**
208
+
209
+ ``` bash
210
+ $ java -Djavax.net.ssl.trustStoreType=KeychainStore \
211
+ -Djavax.net.ssl.trustStore=/Library/Keychains/System.keychain \
212
+ -jar app.jar
213
+ ```
214
+
198
215
### Self Signed Certs
199
216
200
217
#### Using OpenSSL
0 commit comments