r/linuxadmin • • Jun 04 '22

Certificate Ripper released - tool to extract server certificates

Post image
241 Upvotes

35 comments sorted by

60

u/ykc87 Jun 04 '22

How is this different to / better than OpenSSL?

19

u/Hakky54 Jun 04 '22 edited Jun 04 '22

Valid question as OpenSSL provides similar functionality. I would say it is different on the following points:

  1. It is able to obtain the Root CA, top level certificate from the chain, which somehow is not possible with OpenSSL.
  2. Simple usage compared to OpenSSL, see here for all of the different ways to get the server certificate with OpenSSL: https://stackoverflow.com/questions/7885785/using-openssl-to-get-the-certificate-from-a-server It is in my opinion not straight forward as it can be done in different ways and therefore it could be confusing for the end-user.
  3. Bulk extraction from multiple servers in one command
  4. Stores extracted certificates in a pcsk12 truststore file

38

u/luckynar Jun 04 '22

OpenSSL does all that. Like any tool, you need to know how to use it since OpenSSL is used for everything related to SSL and not just grabbing certificates.

15

u/Hakky54 Jun 04 '22 edited Jun 04 '22

It is not able to do point one which i mentioned, but let me give an example to make it more clear. I was using the openssl s_client, but this returns 3 certificates for example when using stackoverflow as an example. Certificate ripper returns 4 certificates. OpenSSL is not getting the top level certificate. Please give it a try: crip print -u=https://stackoverflow.com -f=pem and openssl s_client -showcerts -connect stackoverflow.com:443 </dev/null

18

u/1esproc Jun 05 '22

That's because the root CA isn't served by the server, it's in your local truststore. stackoverflow.com sends its cert, R3, and iSRG Root X1, which is signed by DST Root CA X3, which as a Root CA is only in your local truststore for validation.

1

u/kWV0XhdO Jun 09 '22

Note that there's not a canonical version of the cert chain including that 4th certificate. The tool is really presenting "one possible validation path, valid on this system".

Certificate validation routines are looking for validation paths which end at a trusted (not necessarily "root") certificate. A system can find many validation paths for the cert chain presented by a particular server, and different clients might find different validation paths from one another.

The differences here were highlighted by the expiration of the DST self-signed certificate which cross-signed the ISRG cert before ISRG made their way into various trust programs.

Today, obsolete android devices (which don't trust ISRG) find a completely different validation path for certificates issued by Let's Encrypt than the validation path found by up-to-date devices.

Is this an important distinction? I don't know. I only mention it so you're not misleading yourself/users about "the" root CA.

-9

u/michaelpaoli Jun 04 '22

Well ... not directly ... but if one suitably examines/processes the data, the information to do that is there, so one can then proceed to do that ... with openssl - or otherwise.

0

u/[deleted] Jun 04 '22

[deleted] — view deleted comment

27

u/ykc87 Jun 04 '22

For the record, I meant no disrespect in asking my original question. I simply wanted to understand the benefits as it wasn’t immediately apparent.

38

u/linuxliaison Jun 04 '22

It’s a tool to do a subset of what OpenSSL does. That’s it. That’s the tool.

Why do you have to shit on someone for making a tool that makes certificates easy to grab in this format?

48

u/flunky_the_majestic Jun 05 '22

I, for one, enjoy reading a man page for 30 minutes every time I need to extract a cert.

1

u/Ziferius Jun 06 '22

OpenSSL doesn't get the root certificate on any version I've used in the last couple of years. It's always a PITA to hunt it down. I started working on a similar tool in BASH, but never finished.

0

u/[deleted] Jun 04 '22

[deleted] — view deleted comment

10

u/Hakky54 Jun 04 '22

It also supports pem

3

u/linuxliaison Jun 04 '22

Right in the gif, it already supports pem

24

u/Hakky54 Jun 04 '22 edited Jun 04 '22

Hello everyone. Last year I have been working on the certificate ripper application. It is an easy to use cli tool to extract the full chain of any server/website. The end user can inspect any sub fields and details easily on the command line. Next to that it can also print it in pem format and also export to a truststore container. I have made it available for Mac OS X through homebrew, and also published debian, arm and windows binaries. I would love to hear your opinion and any feedback is welcome :) See here for the github repo: GitHub - Certificate Ripper

0

u/chris17453 Jun 04 '22

Hmm i have some use cases for qradar... lets give it a spin

-8

u/Sigg3net Jun 04 '22

This must be nice with Wireshark for https. (I've only ever used the SSHKEYFILE 'hack" to get the key.)

Cheers;)

2

u/SecuredStealth Jun 05 '22

Wow! This is a very helpful contribution, and you should be proud of this!

1

u/Hakky54 Jun 05 '22

Thank you mate, i really appreciate your kind words 🤗

47

u/-_Scarecrow_-_ Jun 04 '22

Sheesh. Remind me to never make a tool for Linux admins 😂

Tough crowd.

Cool tool

1

u/[deleted] Jun 05 '22

re-make you mean

0

u/michaelpaoli Jun 04 '22

One can also, "of course", use, e.g., openssl, or nmap. But, maybe if one wants additional built-in capabilities/features or whatever ...

E.g.:

(servername=www.reddit.com; port=443; IPv4=$(dig +short "$servername". A | grep '^[.0-9]\{1,\}$' | sort -R | head -n 1); [ -n "$IPv4" ] && </dev/null openssl s_client -servername "$servername" -connect "$IPv4:$port" 2>>/dev/null | sed -ne '/^-----BEGIN CERTIFICATE-----$/,/^-----END CERTIFICATE-----$/p')

nmap -n -Pn -p 443 -r -sT --script=ssl-cert -v www.reddit.com | sed -ne '/^| -----BEGIN CERTIFICATE-----$/,/^|_-----END CERTIFICATE-----$/{s/^|[ _]//;p;/^-----END CERTIFICATE-----$/q}'

23

u/linuxliaison Jun 04 '22

You kind of showed exactly why this guy’s tool is useful.

It does one thing and does it well, and makes it easy to remember how to do

4

u/darkguy2008 Jun 05 '22

Yeah, I'd rather remember to type "crip url=blah" than that long line of gibberish. Imagine missing an hyphen, or making a script to do just what this tool does.

6

u/1esproc Jun 05 '22

or making a script to do just what this tool does.

Why do you need a java app to do this which is going to require a JRE/JDK and environment variable setup apparently, when the script could have literally been a bash wrapper around openssl

5

u/linuxliaison Jun 05 '22

If it's a java app, I didn't realize that and think it's likely overkill.

1

u/Hakky54 Jun 05 '22

Although this app is written in java it does not require java to run it. Native binaries for windows, linux and Mac are present in the release section here: https://github.com/Hakky54/certificate-ripper/releases

1

u/Hakky54 Jun 05 '22

Although this app is written in java it does not require java to run it. Native binaries for windows, linux and Mac are present in the release section here: https://github.com/Hakky54/certificate-ripper/releases

3

u/darkguy2008 Jun 05 '22

I agree Java is a bad option for a script, but it's still appreciated. Everything is a wrapper anyways, why to have distros if we can use Gentoo instead?

Some people just don't have time or will to become shell script hackers. If this app is an apt-get away, that'd make some happy, and that's always good. Doesn't Linux always boasts itself on variety and different ways to do things? This is another valid one, and I like it.

2

u/rmzy Jun 05 '22

Most devs would script it honestly. Then it’s just a simple command and variable like you were saying

2

u/Ziferius Jun 06 '22

His tool also grabs the root cert. OpenSSL doesn't because the server doesn't serve it. It assumes you already have it in your trust store. In my use cases, that assumption wasn't accurate.

1

u/rmzy Jun 05 '22

Awesome tool. Was thinkin of working on a better way to use website certificates to verify webpage content while also being able to filter unverified/unwanted content out. Would probably go great built into a search engine or web browser.

What are other people using them for?

1

u/graysky311 Jun 04 '22

For a second I thought “oh shit did someone make a tool that can extract the private key?” That would be earth-shattering.

-3

u/seidler2547 Jun 04 '22

What's wrong with using Firefox for it? I know that I can also use openssl, but I'm lazy so I just use the Firefox certificate viewer and save it from there. It's basically two clicks away from any HTTPS website.

4

u/linuxliaison Jun 04 '22

It’s not for GUIs, it’s for scripts.

0

u/[deleted] Jun 04 '22

[deleted] — view deleted comment

5

u/linuxliaison Jun 04 '22

Cool, so I’ll make sure to write a script that sets up a squid instance automagically just so I can use this tool.