OpenSSL check p12 expiration date

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

[code]
openssl pkcs12 -in testuser1.pfx -nokeys | openssl x509 -noout -enddate
[/code]
To specify password in plain text, add -passin pass:”${pass}”

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

[code]
openssl pkcs12 -clcerts -nokeys -in myContainer.p12 -out usercert.pem
openssl pkcs12 -nocerts -in myContainer.p12 -out userkey.pem
[/code]

3. Connect to HTTPS server with client certificate:

[code]
openssl s_client -connect gmail.com:443 -cert usercert.pem -key userkey.pem
[/code]

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:

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

To revert this this behaviour to standard, execute

[code]
# dpkg-reconfigure dash
[/code]

dash dpkg-reconfigure debian linux

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

You can check it with following command:

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

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:

[code]
date -d ‘+2 hour’
[/code]

If you want to use specific date as a base:

[code]
date -d ‘2010-01-01 + 2 year’
[/code]