Method: OpenSSL::PKCS7.read_smime

Defined in:
ossl_pkcs7.c

.read_smime(string) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'ossl_pkcs7.c', line 185

static VALUE
ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
{
    BIO *in, *out;
    PKCS7 *pkcs7;
    VALUE ret, data;

    ret = NewPKCS7(cPKCS7);
    in = ossl_obj2bio(&arg);
    out = NULL;
    pkcs7 = SMIME_read_PKCS7(in, &out);
    BIO_free(in);
    if (!pkcs7)
        ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
    if (!pkcs7->d.ptr) {
        PKCS7_free(pkcs7);
        ossl_raise(ePKCS7Error, "No content in PKCS7");
    }

    data = out ? ossl_membio2str(out) : Qnil;
    SetPKCS7(ret, pkcs7);
    ossl_pkcs7_set_data(ret, data);
    ossl_pkcs7_set_err_string(ret, Qnil);

    return ret;
}