How to Find Expiry of SSL Certificates using Command line (certok) using Docker?

certok (cert ok) is a command-line tool that can quickly give you information related to SSL certificates.

If you have go – you can simply install certok inside the system by following command:

go get github.com/genuinetools/certok

Using Docker

I have created a docker image which can be used in place of go tool which is only 11mb in size.

Simply use it like following:

docker run --rm -it -v $(pwd):/app --user $(id -u):$(id -g) varunbatrait/certok:latest

Add it as alias: You can add the following line to your .zshrc file or .bashrc file.

alias certok='docker run --rm -it -v $(pwd):/app --user $(id -u):$(id -g) varunbatrait/certok:latest'

Usage with certok as Docker

Provided that you have added an alias you can use it like following

Create a hostsfile (or any file) with domains

webapplicationconsultant.com
varunbatra.com

Now run dockerized certok using certok

certok hostsfile
// One with Warning
certok --days=50 hostsfile

Sample output

NAME                              SUBJECT                         ISSUER                      ALGO                EXPIRES             SUNSET DATE         ERROR
varunbatra.com:443                *.varunbatra.com                Let's Encrypt Authority X3  SHA256-RSA          81 days                                 
webapplicationconsultant.com:443  *.webapplicationconsultant.com  Let's Encrypt Authority X3  SHA256-RSA          48 days                                 

Worth Sharing?

Dockerized Tor Browsing without Logs

Tor Project is the most popular browser to access internet in complete anonymity. There is a VPN alternative for the tor, However, I am concerned with finishing off as soon as I am done with the browsing.

I have written a one-liner which has no logging and it removes itself

sudo docker run -it  --log-driver none  --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro --entrypoint="/usr/local/bin/Browser/start-tor-browser" jess/tor-browser

–rm tells the docker to clean up the container once it is exit.

–log-driver none gives no logging while it is running.

–entrypoint disables the stdout

You can add an alias in your bashrc or zshrc file as following and access it with tor

alias tor='sudo docker run -it  --log-driver none  --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro --entrypoint="/usr/local/bin/Browser/start-tor-browser" jess/tor-browser'

Worth Sharing?

Why don’t I use array iterators in PHP?

Art VS Performance

When I started learning PHP, most beautiful thing which I could do is to use array_walk, array_map and array_filter functions along with some closure which will attracts some cheers. Today I told my team that they should remove it. But why? The question was raised instantaneously. I said, do the benchmark and you will know the answer.

PHP Functions are overkill! Which should be the part of third party libraries are part of core libraries. Unfortunately, our interview selections make us learn the unwanted core functions. Two years experience favorite question would be different between them! Give it another year and you would know why for loops are great!

Arguably – Performance isn’t much! Check few results over here but then it also depends on how much traffic are you handling. This demands a read on an article on Freaks – Sanity in Insanity I wrote. The overall results from above read is as following:

    //1M numbers across a dozen attempts
    Foreach: 0.7 sec
    Map on closure: 3.4 sec
    Map on function name: 1.2 sec.

But then – Readability!

The functions – array_walk, array_map and array_filter kill the readability all together. It might reduce the number of lines you are reading but – and it is a big but – the loops are more familiar as well as keeps thing in indentation.

Worth Sharing?