You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling PEM_read_bio_PrivateKey() and PEM_read_bio_X509() on the same BIO is broken #14788
If there is both private key and certificate in a file and it is read by calling PEM_read_bio_PrivateKey() and then PEM_read_bio_X509(), the X509 decoding will fail with the current master because when decoding the key the file is completely read and the X509 decoding does not have any data to read.
When you think about the general case, this becomes more complicated. Imagine a file with multiple certs. You don't want to rewind (which you might for cert/key) because you'll keep re-reading the same cert. You don't want to ftell/fseek back to where you were because you'll get the same problem.
It might be cleaner to have a "rewind if necessary" behavior. Or leave it up to the application to do that.
IMO we simply should not regress on this in comparison with 1.1.1. At least not in the simple case of having a key and cert in the file in the same order as it is to be read.
Just to make sure I understand: the file has key and then cert, and calling read-private-key now consumes the whole file so the subsequent call to read-cert fails. If that's the case, then yes, that seems like a bug. Everything else stops when it gets what it is looking for. Is consume the whole file common now? That should be noted if so. But yes I agree the regression should be fixed.
Activity
richsalz commentedon Apr 7, 2021
When you think about the general case, this becomes more complicated. Imagine a file with multiple certs. You don't want to rewind (which you might for cert/key) because you'll keep re-reading the same cert. You don't want to ftell/fseek back to where you were because you'll get the same problem.
It might be cleaner to have a "rewind if necessary" behavior. Or leave it up to the application to do that.
t8m commentedon Apr 7, 2021
IMO we simply should not regress on this in comparison with 1.1.1. At least not in the simple case of having a key and cert in the file in the same order as it is to be read.
richsalz commentedon Apr 7, 2021
Just to make sure I understand: the file has key and then cert, and calling read-private-key now consumes the whole file so the subsequent call to read-cert fails. If that's the case, then yes, that seems like a bug. Everything else stops when it gets what it is looking for. Is consume the whole file common now? That should be noted if so. But yes I agree the regression should be fixed.
t8m commentedon Apr 7, 2021
Yes, your understanding is correct.
Implement pem_read_key directly through OSSL_DECODER