Skip to content

Commit a8845b5

Browse files
committed
chore: more cert commands
1 parent 600497a commit a8845b5

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Writerside/cfg/buildprofiles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd">
44

55
<variables>
6-
<primary-color>emerald</primary-color>
6+
<primary-color>aqua</primary-color>
77
<color-preset>vivid</color-preset>
88
<web-root>https://suresh.dev/</web-root>
99
<custom-favicons>favicon.ico</custom-favicons>

Writerside/topics/notes/Security-Certificates.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ $ keytool -printcert -rfc -sslserver google.com:443 > google.pem
4040

4141
# Show full cert chain (CN, SAN and Expiry) of TLS server
4242
$ 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
4447

4548
# Show just the cert details of a TLS server
4649
$ echo | openssl s_client -showcerts -connect google.com:443 2>/dev/null \
4750
| openssl x509 -inform pem -noout -text
4851

4952
# 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:"
5259

5360
# Extract TLS public keys in Cert pinning format
5461
$ openssl s_client -connect 'dns.google.com:443' 2>&1 < /dev/null \
@@ -151,7 +158,8 @@ $ echo -ne $(cat cert.cer) | openssl rsa -check
151158
$ 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
152159

153160
# 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:"
155163
```
156164

157165
### OpenJDK
@@ -195,6 +203,15 @@ $ keytool -printcert -file /etc/ssl/certs/ca-bundle.crt | grep -i issuer
195203
* [OpenJDK CACerts](https://github.com/openjdk/jdk/tree/master/src/java.base/share/data/cacerts)
196204
* [Android CACerts](https://android.googlesource.com/platform/system/ca-certificates/+/master/files)
197205

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+
198215
### Self Signed Certs
199216

200217
#### Using OpenSSL

0 commit comments

Comments
 (0)