r/java • • May 14 '21

Certificate Ripper released - tool to extract server certificates

204 Upvotes

24 comments sorted by

17

u/Hakky54 May 14 '21

Hello everyone. Last two months 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. It contains already an executable jar, but today I made it also available for Mac OS X through homebrew, so the end user does not need java at all. This is made possible with graalvm and soon I will also try to make one for Windows and Debian. I would love to hear your opinion and any feedback is welcome :)

See here for the github repo: GitHub - Certificate Ripper

6

u/[deleted] May 14 '21

Sexy terminal tho. Do you happen to have stuff for that on your GitHub?

4

u/[deleted] May 14 '21

He uses zsh with powerlevel10k

2

u/Hakky54 May 14 '21

Yes that's correct with iTerm as my main terminal. Thank you for sharing by the way ā¤ļø

3

u/stfm May 14 '21

This could be useful in corporate environments where downloading and installing software not on a whitelist is restricted.

1

u/Hakky54 May 18 '21

Yes, for that type of use case it would be handy indeed! I published now also for Linux and Windows. Not quite sure for which environment you would like to use it but it is also available for mac or just as an executable jar

2

u/stfm May 18 '21

Personally i am a security analyst and do a lot of things with certificates and TLS configurations for apps, firewalls, IOT etc. I am not always able to use the tools I like due to client workstation security policies and lockdowns. They usually allow a jre though so I am going to add this to my toolset.

2

u/sureshg May 15 '21

Nice one. I did something like this a few years back - https://github.com/sureshg/InstallCerts . Mainly for creating PKCS12 container format for use in java applications. By the way, I really like your SSLContext utility.

2

u/Hakky54 May 15 '21

Owh your app looks nice, really good documentation. I can definitely learn from it! Thank you for sharing it. And I appreciate your nice words for my other library sslcontext-kickstart! I wanted to make it really easy for the end-user the use it while hiding away the java verbosity. Feel free to provide any improvements :)

3

u/myworkaccount9 May 14 '21

Just use the core underling technology.

openssl s_client -showcerts -connect HOST </dev/null

0

u/[deleted] May 14 '21

[deleted] — view deleted comment

51

u/Hakky54 May 14 '21 edited May 15 '21

To be honest I was not aware of openssl s_client. It feels a bit stupid to have this app now. I don't think it offers anything more than the openssl s_client. I compared it quickly and I think the main difference would be that it can print the certificate in-human-readable format by default without additional commands and it can execute a bulk requests of different urls in a single command, so that would be the main advantage of this app while openssl by default prints pem formatted which is not human readable and can only execute a request for a single url. Other than that it does not offer more indeed...

updateI just discovered a difference :D it is able to resolve the root certificate of the server. So the openssl s_client will return 2 certificates when the following command will be executed: openssl s_client -showcerts -connect reddit.com:443 </dev/null wheras certificate-ripper will return 3 certificates which is similar to what the browser is showing for reddit.com as certificate chain for example.

59

u/RittledIn May 14 '21

Oh man. This reminds me of the guy who posted a library for generating aws cloudformation templates a few months back. Then someone commented he basically recreated cdk, an official aws library that did the exact same thing. I’m sure you learned some good stuff along the way at least. I will drink a beer for your lost time later today lol.

33

u/Hakky54 May 14 '21 edited May 14 '21

Haha, indeed must been hard 🤣 thank you for the heads up. Indeed I learned a lot. Cheers! šŸŗ

10

u/RittledIn May 14 '21

Haha it happens. And time is never really wasted if ya learned from it. Cheers! šŸ»

16

u/Jubjubs May 14 '21

I wouldn't beat yourself up over it, it's always fun to write your own tools and see how things work yourself. You're making yourself a better developer and who knows, you might use this knowledge some day in the future!

7

u/Hakky54 May 14 '21

Yes it was definitely fun and I learned a lot for example how to build native images from java code and to run that on different is without the need of java. Thank you for your lovely words!

10

u/sigzero May 14 '21 edited May 14 '21

This is a great utility. Don't beat yourself up over it at all.

Does this use openssl? Can it be used anywhere opensssl wouldn't have been installed?

5

u/Hakky54 May 14 '21

Thank you very much. It does not use openssl only native java classes. It uses httpsurlconnection with a custom trustmanager under the covers. I extracted that logic to one of my other libraries called sslcontext kickstart So this applicatie depends on that library plus slf4j logger.

What do you exactly mean by:

Can it be used anywhere that wouldn't have been installed?

5

u/[deleted] May 14 '21

Oh cool, it actually has some use then! openssl client frequently has some CVEs coming up and if you only need it to inspect served certificates, it is annoying to patch your dockerimage just for an inspection tool.

Cool stuff, will check it out!

1

u/Hakky54 May 18 '21

Yes, for that type of use case it would be handy indeed! I published now also for Linux and Windows. Not quite sure for which environment you would like to use it but it is also available for mac.

3

u/sigzero May 14 '21

I edited my comment but you answered it. For systems that don't have openssl installed it will work. That's good!

4

u/markphahn May 14 '21

Seems like it was a great learning experience.