An open API service indexing awesome lists of open source software.

https://github.com/hakky54/certificate-ripper

🔐 A CLI tool to extract server certificates
https://github.com/hakky54/certificate-ripper

certificate graal-native graalvm graalvm-native-image homebrew homebrew-tap java macos ssl testing testing-tools tls x509

Last synced: 7 days ago
JSON representation

🔐 A CLI tool to extract server certificates

Awesome Lists containing this project

README

          

[![Actions Status](https://github.com/Hakky54/certificate-ripper/workflows/Build/badge.svg)](https://github.com/Hakky54/certificate-ripper/actions)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=io.github.hakky54%3Acertificate-ripper&metric=security_rating)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Acertificate-ripper)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=io.github.hakky54%3Acertificate-ripper&metric=coverage)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Acertificate-ripper)
[![Apache2 license](https://img.shields.io/badge/license-Aache2.0-blue.svg)](https://github.com/Hakky54/sslcontext-kickstart/blob/master/LICENSE)
[![GitHub stars chart](https://img.shields.io/badge/github%20stars-chart-blue.svg)](https://seladb.github.io/StarTrack-js/#/preload?r=hakky54,certificate-ripper)

[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/dashboard?id=io.github.hakky54%3Acertificate-ripper)

# Certificate Ripper 🔐
A CLI tool to extract server certificates

# Introduction
Certificate ripper came to life when I was curious to learn about writing OS native apps. It started as a pet project and I wanted to create a native app by writing it in Java.
During my work I discovered that extracting certificates in other tools can sometimes be troublesome, so I used that as a use-case to create an app in Java, compile that to native OS app so others don't need Java to run it.
It made my work easier for maintaining trust-stores and I hope it made others life also easier.

I have created this tool with ❤️ and passion, mostly during evening and night hours. If you use my tool and want to appreciate the work I have done, please consider to sponsor this project as a way to contribute back to the community.
There are 3 options available to pick from: [GitHub](https://github.com/sponsors/Hakky54), [Ko-fi](https://ko-fi.com/hakky54) and [Open Collective](https://opencollective.com/hakky54)

## Demo
![alt text](https://github.com/Hakky54/certificate-ripper/blob/master/images/demo.gif?raw=true)

## Advantages
- It is fast
- Easy to use
- No openssl required
- Runs on any Operating System
- Can be used with or without Java, native executables are present in the releases
- Extracts all the sub-fields of the certificate
- Certificates can be formatted to PEM format
- Bulk extraction of multiple different urls with a single command is possible
- Extracted certificates can be stored automatically into a p12 truststore
- Works also behind a proxy
- Supported protocols:
- https (Hypertext Transfer Protocol Secure)
- wss (WebSocket Secure)
- ftps (File Transfer Protocol Secure)
- smtps (Simple Mail Transfer Protocol Secure)
- imaps (Internet Message Access Protocol Secure)
- Database:
- PostgreSQL
- MySQL

## Installing

The executables are available for download in the [Releases](https://github.com/Hakky54/certificate-ripper/releases). Alternatively you can also install the tool using one of the following methods:

- Mac OS X & Linux - Homebrew 🍺
- Run `brew install crip`
- Mac OS X & Linux - Homebrew with native binary 🍺
- Run `brew install hakky54/homebrew-apps/crip`
- Linux - Debian/Ubuntu (apt) 📦
- Run `sudo add-apt-repository ppa:hakky554/apps && sudo apt update && sudo apt-get install crip -t 'o=LP-PPA-hakky554-apps'`
- Linux & Windows
- Download the latest binary here: [Releases](https://github.com/Hakky54/certificate-ripper/releases)
- Nintendo 3DS 🎮
- Find the latest release and installation instructions here: [3DS Certificate Ripper](https://github.com/Hakky54/3ds-certificate-ripper)

#### Contributed/Unofficial Installation Methods
- Arch-Linux (AUR)
- Install the [certificate-ripper-bin](https://aur.archlinux.org/packages/certificate-ripper-bin) AUR package
- NixOS ([nixpkgs](https://search.nixos.org/packages?channel=25.11&show=certificate-ripper&query=certificate+ripper))
- Run `nix-shell -p certificate-ripper` or add `pkgs.certificate-ripper` to your `configuration.nix` file
- [Sourceforge](https://sourceforge.net/projects/certificate-ripper.mirror/)
- Windows
- [Chocolatey](https://community.chocolatey.org/packages/crip) 🍫
- Run `choco install crip`
- [Scoop](https://scoop.sh/#/apps?q=crip&p=1) 🍨
- Run `scoop install extras/crip`

## Build locally

Build native executable

**Minimum requirements:**
1. GraalVM 24 with Native Image
2. Maven
3. Terminal

**Additional OS specific requirements**
- Linux: `sudo apt-get update && sudo apt-get install build-essential libz-dev zlib1g-dev -y`
- Mac: `xcode-select --install`
- Windows: Visual Studio app and ensure `chcp 65001` (UTF-8 encoding) is active in the command line

```text
mvn clean install -Pnative-image \
&& ./target/crip print --url=https://youtube.com/
```

The os native executable binary will be available under the target directory having the file name `crip`

Build java fat jar

**Minimum requirements:**
1. Java 21
2. Maven
3. Terminal

```text
mvn clean install -Pfat-jar \
&& java -jar target/crip.jar print --url=https://youtube.com/
```

The fat jar will be available under the target directory having the file name `crip.jar`

## CLI Options
```text
Usage: crip [COMMAND]
Commands:
print Prints the extracted certificates to the console
export p12 Export the extracted certificate to a PKCS12/p12 type truststore
export jks Export the extracted certificate to a JKS (Java KeyStore) type truststore
export der Export the extracted certificate to a binary form also known as DER
export pem Export the extracted certificate to a base64 encoded string also known as PEM

Usage: crip print
Prints the extracted certificates to the console
-f, --format To be printed certificate format. This option is not required. Default is human-readable.
-u, --url Url of the target server to extract the certificates. Can be provided multiple times.

Usage: crip export pkcs12
Export the extracted certificate to a PKCS12/p12 type truststore
-u, --url Url of the target server to extract the certificates. Can be provided multiple times.
-p, --password TrustStore password. This option is not required. Default is changeit.
-d, --destination Destination of the to be stored file. Default is current directory if none is provided.

Usage: crip export der
Export the extracted certificate to a binary form also known as DER
-u, --url Url of the target server to extract the certificates. Can be provided multiple times.
-c, --combined Indicator to either combine all of the certificate into one file for a given url or export into individual files.
-d, --destination Destination of the to be stored file. Default is current directory if none is provided.

Usage: crip export pem
Export the extracted certificate to a base64 encoded string also known as PEM
-u, --url Url of the target server to extract the certificates. Can be provided multiple times.
-c, --combined Indicator to either combine all of the certificate into one file for a given url or export into individual files.
-d, --destination Destination of the to be stored file. Default is current directory if none is provided.
--include-header Indicator to either omit or include additional information above the BEGIN statement.

Other additional options applicable for all commands
--proxy-host Proxy host
--proxy-port Proxy port
--proxy-password Password for authenticating the user for the given proxy
--proxy-user User for authenticating the user for the given proxy
-t, --timeout Amount of milliseconds till the ripping should timeout
--resolve-ca Indicator to automatically resolve the root ca. Possible options: true, false
--resolve-siblings Indicator to automatically resolve the certificates from DNS names. Possible options: true, false
--cert-type To be extracted certificate types. Available Formats: root, inter, leaf, all. Default: all
```

## Example usages
### Single export
```bash
crip export pkcs12 -u=https://github.com
```

### Bulk export
```bash
crip export pkcs12 \
-u=https://youtube.com \
-u=https://github.com \
-u=https://stackoverflow.com \
-u=https://facebook.com
```

### Specify custom truststore destination path
```bash
crip export pkcs12 -u=https://github.com -d=/path/to/directory
```

### Print in human-readable format
```bash
crip print -u=https://github.com
```

### Print in PEM format
```bash
crip print -u=https://github.com -f=pem
```

### Batch print in PEM format
```bash
crip print -f=pem \
-u=https://youtube.com \
-u=https://github.com \
-u=https://stackoverflow.com \
-u=https://facebook.com
```

### Extracting behind a proxy
```bash
crip export pem \
-u=https://stackoverflow.com \
--proxy-host=my-host.com \
--proxy-port=1234 \
--proxy-user=foo \
--proxy-password
```

### Combining certificates
```bash
crip export pem -u=https://github.com --combined=true
```

### Defining custom file name
Works only with the combined option while only specifying a single url.
```bash
crip export pem -u=https://github.com --combined=true --destination=/path/to/export/github-chain.crt
```

### Trust additional certificates into Java Cacerts Keystore
```bash
crip export p12 -d=path/to/lib/security/cacerts -p=changeit -u=https://google.com
```

### Export other sources
```bash
# Operating System trusted certificates
crip export pem -u=system

# Websocket server
crip export pem -u=wss://echo.websocket.org

# FTP server
crip export pem -u=ftps://my-drive.com:21

# SMTP server
crip export pem -u=smtps://smtp-mail.outlook.com:587

# IMAP server
crip export pem -u=imaps://outlook.office365.com:993

# PostgreSQL server
crip export pem -u=postgresql://localhost:5432/

# MySQL server
crip export pem -u=mysql://localhost:3306/
```

### Filter on certificate types
The to be extracted certificates can be filtered to include only root ca, intermediate or leaf certificates. An example is shown below:
```bash
crip export der -u=https://google.com --cert-type=root
```
Other values for the cert-type option are: inter and leaf. When the option is not provided all of the certificates are extracted.

### Extracting with Java DSL
Include the following dependency:
```xml

io.github.hakky54
certificate-ripper
2.7.1

```

Example code snippet:
```text
CertificateRipper.exportToPem("https://github.com")
.withIncludeHeader(false)
.withCombined(true)
.withDestination("/path/to/export/github-chain.crt")
.build()
.run();
```

## Contributing

There are plenty of ways to contribute to this project:

* Give it a star
* Make a donation through [GitHub](https://github.com/sponsors/Hakky54) or [open collective](https://opencollective.com/hakky54)
* Share it with a [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Easily%20extract%20server%20certificates&url=https://github.com/Hakky54/certificate-ripper&via=hakky541&hashtags=certificate,security,https,ssl,tls,developer,java)
* Submit a PR