OpenSSL check p12 expiration date

1. Check .p12 / .pfx certificate expiration date:

openssl pkcs12 -in testuser1.pfx -nokeys | openssl x509 -noout -enddate

To specify password in plain text, add -passin pass:”${pass}”

2. Export key and cert from .p12 / .pfx:

openssl pkcs12 -clcerts -nokeys -in myContainer.p12 -out usercert.pem
openssl pkcs12 -nocerts  -in myContainer.p12 -out userkey.pem

3. Connect to HTTPS server with client certificate:

openssl s_client -connect -cert usercert.pem -key userkey.pem

PHP exec system calls not working in Debian 6

After migrating Current website to Debian 6, PHP calls exec and system stopped working.
The reason for it is debian package dash which modifies behaviour of system default shell:

# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec  9 20:25 /bin/sh -> dash

To revert this this behaviour to standard, execute

# dpkg-reconfigure dash

dash dpkg-reconfigure debian linux

Select “No” and default shell will be changed to standard bash.

You can check it with following command:

# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec  9 20:26 /bin/sh -> bash

Add / substract time in bash

To add or substract any amount of seconds, minutes, hours, days, weeks, months or years to/from current date use the Linux date command:

date -d '+2 hour'

If you want to use specific date as a base:

date -d '2010-01-01 + 2 year'