Skip to content

Commit

Permalink
add cli tool
Browse files Browse the repository at this point in the history
  • Loading branch information
mchl18 committed Jan 14, 2025
1 parent 214a0b9 commit 8a02f02
Show file tree
Hide file tree
Showing 7 changed files with 478 additions and 30 deletions.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,92 @@ npx cap sync
openssl x509 -noout -fingerprint -sha256 -inform pem -in /path/to/cert.pem
```

### Via Built-in CLI Tool

This package includes a CLI tool that can fetch and display SSL certificate information for any domain.

Install globally:
```bash
npm install -g capacitor-ssl-pinning
# or
yarn global add capacitor-ssl-pinning
```

Or use it in your project:
```bash
npm install capacitor-ssl-pinning
# or
yarn add capacitor-ssl-pinning
```

Usage:
```bash
# Using npx command
npx ssl-fingerprint example.com

# Or if installed globally
ssl-fingerprint example.com

# Save output to a file
ssl-fingerprint example.com --out certs.json

# Save just the fingerprints in TypeScript format
ssl-fingerprint example.com --out fingerprints.ts --format fingerprints
```

You can also add it as a script in your package.json:
```json
{
"scripts": {
"generate-fingerprint": "ssl-fingerprint example.com"
}
}
```

Then run it with:
```bash
npm run generate-fingerprint
```

The tool will display:
- Domain name
- Certificate subject
- Certificate issuer
- Valid from date
- Valid to date
- SHA256 fingerprint

Example output:
```json
[
{
"domain": "example.com",
"subject": {
"C": "US",
"ST": "California",
"L": "Los Angeles",
"O": "Internet Corporation for Assigned Names and Numbers",
"CN": "www.example.org"
},
"issuer": {
"C": "US",
"O": "DigiCert Inc",
"CN": "DigiCert Global G2 TLS RSA SHA256 2020 CA1"
},
"validFrom": "Jan 30 00:00:00 2024 GMT",
"validTo": "Mar 1 23:59:59 2025 GMT",
"fingerprint": "EF:BA:26:D8:C1:CE:37:79:AC:77:63:0A:90:F8:21:63:A3:D6:89:2E:D6:AF:EE:40:86:72:CF:19:EB:A7:A3:62"
}
]
```

When using `--format fingerprints`, the output will be in TypeScript format:
```typescript
export const fingerprints = [
"EF:BA:26:D8:C1:CE:37:79:AC:77:63:0A:90:F8:21:63:A3:D6:89:2E:D6:AF:EE:40:86:72:CF:19:EB:A7:A3:62"
];
```

## API

### `checkCertificate`
Expand Down
204 changes: 201 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a02f02

Please sign in to comment.