Hakky54 / certificate-ripper

🔐 A CLI tool to extract server certificates
Apache License 2.0
714 stars 66 forks source link

Allow to set timeout when destination not reachable #22

Closed OneCyrus closed 9 months ago

OneCyrus commented 9 months ago

Is your feature request related to a problem? Please describe. We are using crip in dockerfiles for devcontainers and fetch some certs to trust them. Unfortunately some urls are not always accessible and this leads to crip hanging for minutes when it doesn't reach its destination.

Describe the solution you'd like use a sensible default (couple seconds) or allow to specify a timeout which is much shorter than minutes.

Describe alternatives you've considered build logic around crip which checks if the destination is reachable before calling crip.

Hakky54 commented 9 months ago

Thank you for raising this issue, I was not aware that it could get stuck for so long. With the current implementation it will wait till the server responds, it will just wait infinity. However that can be easily adjusted. I have configured it with a default value of 1000 milliseconds which is equal to 1 second. Next to that I will add a command line argument where it will be possible to override the default timeout

Hakky54 commented 9 months ago

@OneCyrus I have made the changes to have this option. It has an additional option -t and an alias --timeout. The provided value will be amount of milliseconds till it wait for the server to respond or else it will skip it. You can have a look at the PR https://github.com/Hakky54/certificate-ripper/pull/23 and check if something is missing or fine for your use case. Looking forward to your reply.

OneCyrus commented 9 months ago

@Hakky54 thanks! as far as I can tell it looks good 👍 if you have a build artifact (couldn't find one attached to the pipeline) i can give this a try.

Hakky54 commented 9 months ago

Awesome, thank you! I don't have a build artifact as it is not part of the ci/cd. However I have added couple of tests like the one below to cover your use case:

https://github.com/Hakky54/certificate-ripper/pull/23/files#diff-971a20eb3bdc0e749c44f9bc0c0552c7ecc115a814ed5479f7a25ba870923072R117

When I create an artifact I can you ping you so you can try it out on your side. I expect that it will be available this week.

Hakky54 commented 9 months ago

@OneCyrus I have published the new artifacts in the releases section. The latest changes are now in version 2.3.0

OneCyrus commented 9 months ago

@Hakky54 works great! thanks!