Wednesday, March 16, 2022

[SOLVED] Openssl command does not run in crontab only for a specific certificate

Issue

I have a SH script in Ubuntu server 16 that I run to get the enddate of a certificate:

openssl pkcs12 -in cert.p12 -clcerts -nodes -passin file:passwordfile | openssl x509 -noout -enddate

This runs well for several certificates but for only one it does not run. I check the file permissions for all certificates and all have the same permissions. The password in the file is also correct. If the script is called by the crontab it does not return the date. If i run in the command line it works as expected. I create a node JS file to do the same and also it works for all certificates except the same one and again it works in command line.

The password for the file has accent characters. It works with command line but not running from crontab. Could this be the cause somehow?

I am using: OpenSSL 1.1.1e 17 Mar 2020 Ubuntu 16.04.6 LTS

And according to https://www.openssl.org/docs/man1.1.1/man7/passphrase-encoding.html it accepts UTF8. Any ideas why this does not run only for a specific certificate? Thank you.

UPDATE: I upgrade the OpenSSL to 1.1.1g and the problem remains. I test with Ubuntu 20.04 and the problem does not occur.


Solution

It was a problem of path in the crontab job. Just added: PATH=/usr/local/bin:/usr/local/ssl/bin:/usr/bin:/bin: before the job and solved the problem.



Answered By - Kaspacainoombro
Answer Checked By - Marilyn (WPSolving Volunteer)