Crypt-OpenSSL-PKCS12
view release on metacpan or search on metacpan
ERR_print_errors_fp(stderr);
croak("Error creating PKCS#12 structure\n");
}
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
i2d_PKCS12_bio(bio, p12);
RETVAL = extractBioString(aTHX_ bio);
PKCS12_free(p12);
OUTPUT:
RETVAL
SV*
certificate(pkcs12, pwd = "")
Crypt::OpenSSL::PKCS12 pkcs12
char *pwd
PREINIT:
BIO *bio;
STACK_OF(PKCS7) *asafes = NULL;
CODE:
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
RETVAL = newSVpvn("",0);
dump_certs_keys_p12(aTHX_ bio, pkcs12, pwd, strlen(pwd), CLCERTS|NOKEYS, NULL, NULL);
RETVAL = extractBioString(aTHX_ bio);
OUTPUT:
RETVAL
SV*
ca_certificate(pkcs12, pwd = "")
Crypt::OpenSSL::PKCS12 pkcs12
char *pwd
PREINIT:
BIO *bio;
STACK_OF(PKCS7) *asafes = NULL;
CODE:
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
RETVAL = newSVpvn("",0);
dump_certs_keys_p12(aTHX_ bio, pkcs12, pwd, strlen(pwd), CACERTS|NOKEYS, NULL, NULL);
RETVAL = extractBioString(aTHX_ bio);
OUTPUT:
RETVAL
SV*
private_key(pkcs12, pwd = "")
Crypt::OpenSSL::PKCS12 pkcs12
char *pwd
PREINIT:
BIO *bio;
CODE:
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
PKCS12_unpack_authsafes(pkcs12);
dump_certs_keys_p12(aTHX_ bio, pkcs12, pwd, strlen(pwd), NOCERTS, NULL, NULL);
RETVAL = extractBioString(aTHX_ bio);
OUTPUT:
RETVAL
HV* info_as_hash(pkcs12, pwd = "")
Crypt::OpenSSL::PKCS12 pkcs12
char *pwd
PREINIT:
BIO *bio;
STACK_OF(PKCS7) *asafes = NULL;
CONST_ASN1_INTEGER *tmaciter;
#if OPENSSL_VERSION_NUMBER > 0x10100000L
SV *value;
CONST_X509_ALGOR *macalgid;
CONST_ASN1_OBJECT *macobj;
CONST_ASN1_OCTET_STRING *tmac;
CONST_ASN1_OCTET_STRING *tsalt;
#endif
CODE:
RETVAL = newHV();
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
RETVAL = newHV();
HV * mac = newHV();
#if OPENSSL_VERSION_NUMBER > 0x10100000L
PKCS12_get0_mac(&tmac, &macalgid, &tsalt, &tmaciter, pkcs12);
/* current hash algorithms do not use parameters so extract just name,
in future alg_print() may be needed */
X509_ALGOR_get0(&macobj, NULL, NULL, macalgid);
i2a_ASN1_OBJECT(bio, macobj);
value = extractBioString(aTHX_ bio);
if((hv_store(mac, "digest", strlen("digest"), value, 0)) == NULL)
croak("unable to add digest to the hash");
#else
tmaciter = pkcs12->mac->iter;
#endif
SV * mac_iteration = newSViv (tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L);
if((hv_store(mac, "iteration", strlen("iteration"), mac_iteration, 0)) == NULL)
croak("unable to add iteration to the hash");
( run in 1.220 second using v1.01-cache-2.11-cpan-39bf76dae61 )