OpenSSL `rehash` fails silently when there's a private key file being rehashed.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 30.8k
- Forks
- 11.5k
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
Postfix on Ubuntu wouldn't start. It turned out to be caused by a totally incorrect file with .pem extension in /etc/ssl/certs that contained a EC PRIVATE KEY. Shouldn't be there in the 1st place. But this in turn makes openssl rehash /path/to/certs fail silently and exit with error level 1. And that broke Postfix' startup helper script.
It would have saved me quite some time debugging this if openssl rehash would log something about why it exit(1)'d, or it'd just log a warning and ignored the file like when it does when a .pem-file doesn't contain a certificate or CRL
Examples:
This is fine:
$ mkdir -p test
$ cd test
$ cp /etc/ssl/certs/*pem .
$ openssl rehash . ; echo $?
0
This is fine too, a warning was logged, exit level is 0:
$ date > broken.pem
$ openssl rehash . ; echo $?
rehash: warning: skipping broken.pem, it does not contain exactly one certificate or CRL
0
This is not fine. I would expect an error message here. Or a warning and error level 0.
$ openssl ecparam -name prime256v1 -genkey -noout -out broken.pem
$ openssl rehash . ; echo $?
1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the openssl rehash command and a .pem file containing an EC private key, comparing it with the broken-file warning case shown in the report. Trace the rehash entry point's handling of private-key files; done means it reports why the file was skipped or failed and has the intended exit status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cli, cryptography
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100