Skip to content

Commit

Permalink
updated documentation to reflected the help
Browse files Browse the repository at this point in the history
removed the $ to simplify copying commands from github
  • Loading branch information
andreburgaud committed Dec 23, 2023
1 parent d0dbea7 commit 7408a33
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@

`showcert` displays SSL certificate attributes in JSON format.

The target can be a local file or a remote server. In the latter scenario,
The target can be a local file or a remote server. In the latter scenario,
the argument is a server name and port if different from the default TLS port 443.

## Examples

The simplest example would be something like:

```
$ showcert google.com
showcert google.com
```

For more details about the options available with `showcert`, execute `showcert` with the `--help` option:

```
$ showcert --help
showcert --help
```

```
showcert shows details about local or remote SSL certificates
USAGE:
Expand All @@ -26,25 +28,27 @@ USAGE:
FLAGS:
-h, --help Displays this help
-V, --version Displays application version
-c, --cert <cert_file> Parses a local certificate file
--cafile <PEM_file> Loads CAs from a PEM file
-d, --domain <domain_name> Parses a remote certificate
-f, --file <cert_file> Parses a local certificate file (PEM format)
-v, --verify Requires certificate chain verification
--host <host:[port]> Parses a remote certificate for a given host
--cafile <PEM_file> Loads CAs from a PEM file
--cadir <directory> Loads CAs from a directory containing PEM files
EXAMPLES:
showcert google.com
showcert --domain google.com
showcert --domain google.com:443
showcert --host google.com
showcert --host google.com:443
showcert --verify google.com
showcert --verify --domain google.com
showcert --cert some_cert.pem
showcert --file some_cert.pem
showcert --cafile some_ca.pem
showcert --cadir some_directory
```

For a better user experience, you can pipe the `showcert` JSON output to [jq](https://stedolan.github.io/jq/).

```
$ showcert --verify google.com | jq
showcert --verify google.com | jq
```
```json
{
Expand Down Expand Up @@ -89,7 +93,9 @@ To extract a specific attribute of the JSON file, you can use `jq`. Here are som
Extract the first raw PEM certificate:

```
$ showcert google.com | jq -r '.chains[0].certificates[0].pem'
showcert google.com | jq -r '.chains[0].certificates[0].pem'
```
```
-----BEGIN CERTIFICATE-----
MIIN7jCCDNagAwIBAgIRAKz/vGtNq+cyCkMq+UTzB2MwDQYJKoZIhvcNAQELBQAw
RjELMAkGA1UEBhMCVVMxIjAgBgNVBAoTGUdvb2dsZSBUcnVzdCBTZXJ2aWNlcyBM
Expand All @@ -99,7 +105,9 @@ RjELMAkGA1UEBhMCVVMxIjAgBgNVBAoTGUdvb2dsZSBUcnVzdCBTZXJ2aWNlcyBM
List all the SHA256 fingerprints:

```
$ showcert --verify google.com | jq '.chains[].certificates[].sha256_fingerprint'
showcert --verify google.com | jq '.chains[].certificates[].sha256_fingerprint'
```
```
"6D:8C:E1:6A:5C:A3:F0:91:40:DE:07:37:AD:4A:AD:DA:66:6A:AF:14:16:AB:9F:4E:7E:E8:40:8B:E9:1B:7B:F3"
"23:EC:B0:3E:EC:17:33:8C:4E:33:A6:B4:8A:41:DC:3C:DA:12:28:1B:BC:3F:F8:13:C0:58:9D:6C:C2:38:75:22"
"2A:57:54:71:E3:13:40:BC:21:58:1C:BD:2C:F1:3E:15:84:63:20:3E:CE:94:BC:F9:D3:CC:19:6B:F0:9A:54:72"
Expand All @@ -112,7 +120,9 @@ $ showcert --verify google.com | jq '.chains[].certificates[].sha256_fingerprint
Display all authority key ids for CA certificates:

```
$ showcert --verify google.com | jq '.chains[].certificates[] | select(.certificate_authority == true) | .authority_key_id'
showcert --verify google.com | jq '.chains[].certificates[] | select(.certificate_authority == true) | .authority_key_id'
```
```
"E4:AF:2B:26:71:1A:2B:48:27:85:2F:52:66:2C:EF:F0:89:13:71:3E"
null
"E4:AF:2B:26:71:1A:2B:48:27:85:2F:52:66:2C:EF:F0:89:13:71:3E"
Expand All @@ -127,21 +137,21 @@ A docker image is available at https://hub.docker.com/r/andreburgaud/showcert.
To use the image and fetch the Google certificates:

```
$ docker run --rm andreburgaud/showcert google.com
docker run --rm andreburgaud/showcert google.com
...
```

You can also pipe the result to [jq](https://stedolan.github.io/jq/):

```
$ docker run --rm andreburgaud/showcert google.com | jq
docker run --rm andreburgaud/showcert google.com | jq
...
```

or to extract only the first certificate in PEM format:

```
$ docker run --rm andreburgaud/showcert google.com | jq -r '.chains[0].certificates[0].pem'
docker run --rm andreburgaud/showcert google.com | jq -r '.chains[0].certificates[0].pem'
...
```

Expand All @@ -151,33 +161,33 @@ $ docker run --rm andreburgaud/showcert google.com | jq -r '.chains[0].certifica

If you have [just](https://github.com/casey/just) and [Go](https://go.dev/) installed:
```
$ just build
just build
```

If you only have [Go](https://go.dev/) installed:

```
$ go build -o showcert showcert/cmd/showcert
go build -o showcert showcert/cmd/showcert
```

### Release

`Showcert` uses [GoReaser](https://goreleaser.com/) to cross-compile the project and deploy binaries to GitHub.
`Showcert` uses [GoReaser](https://goreleaser.com/) to cross-compile the project and deploy binaries to GitHub.

To generate a local release, you can execute the following command

```
$ just local-release
just local-release
```

If you only have [Go](https://go.dev/) installed:

```
$ go build -o showcert -ldflags="-s -w -X 'showcert/internal/cli.Version=1.2.3'" showcert/cmd/showcert
go build -o showcert -ldflags="-s -w -X 'showcert/internal/cli.Version=1.2.3'" showcert/cmd/showcert
```

## License

The `showcert` source code is released under the [MIT license](LICENSE).
The `showcert` source code is released under the [MIT license](LICENSE).

`showcert` includes some code from [CFSSL](https://github.com/cloudflare/cfssl) released under a BSD-2-Clause license. References to `CFSSL` are included in the appropriate `showcert` files.

0 comments on commit 7408a33

Please sign in to comment.