Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
OpenSSL::PKCS7.new
(?::String der) -> ::OpenSSL::PKCS7
PKCS7.new => pkcs7
PKCS7.new(string) => pkcs7
ext/openssl/ossl_pkcs7.c
View on GitHub ↗
static VALUE
ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
{
PKCS7 *p7;
BIO *in;
VALUE arg;
rb_scan_args(argc, argv, "01", &arg);
ossl_want_uninitialized(self, &ossl_pkcs7_type);
if (argc == 0) {
p7 = PKCS7_new();
if (!p7)
ossl_raise(ePKCS7Error, "PKCS7_new");
RTYPEDDATA_DATA(self) = p7;
return self;
}
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
p7 = d2i_PKCS7_bio(in, NULL);
if (!p7) {
OSSL_BIO_reset(in);
p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL);
}
BIO_free(in);
if (!p7)
ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
if (!p7->d.ptr) {
PKCS7_free(p7);
ossl_raise(ePKCS7Error, "No content in PKCS7");
}
RTYPEDDATA_DATA(self) = p7;
ossl_pkcs7_set_data(self, Qnil);
ossl_pkcs7_set_err_string(self, Qnil);
return self;
}
Many methods in this class aren’t documented.