wahern / luaossl

Most comprehensive OpenSSL module in the Lua universe.
http://25thandclement.com/~william/projects/luaossl.html
Other
140 stars 49 forks source link

src/openssl.c: reset bio pointer before reuse in X509_ANY format #177

Closed fffonion closed 4 years ago

fffonion commented 4 years ago

In x509.new(), csr.new(), and crl.new() when it's initialized from a DER text and format is * or unset, the same BIO struct is reused for two times. While the pointer is already modified in PEM_read_bio_*, later d2i_*_bio call will always fail.

This patch resets the BIO after first use so that DER format can be correctly loaded.

local f = io.open("a_der_formated_crl.crl"):read("*a")
require("openssl.x509.crl").new(f)
-- ERROR: x509.crl.new: asn1_lib.c:101:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
daurnimator commented 4 years ago

Could you add a regression test?

fffonion commented 4 years ago

Yes, I just added regression test.