diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-11-10 23:54:04 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-11-10 23:54:04 +0100 |
commit | f565d0c575f9d7e4a53e10ee447871fea21cb2e3 (patch) | |
tree | 950b57b988a21db56ded2da3892cfad4dea6b9d4 /src/pluto/builder.c | |
parent | cc543182bcf79b306188262b5537bc55f89c0965 (diff) | |
download | strongswan-f565d0c575f9d7e4a53e10ee447871fea21cb2e3.tar.bz2 strongswan-f565d0c575f9d7e4a53e10ee447871fea21cb2e3.tar.xz |
merged pluto's PGP certificate parsing with charon's
Diffstat (limited to 'src/pluto/builder.c')
-rw-r--r-- | src/pluto/builder.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/src/pluto/builder.c b/src/pluto/builder.c index 6c7cde547..0cba32bcf 100644 --- a/src/pluto/builder.c +++ b/src/pluto/builder.c @@ -64,43 +64,31 @@ static cert_t *builder_load_cert(certificate_type_t type, va_list args) } if (blob.ptr) { + cert_t *cert = malloc_thing(cert_t); + + *cert = cert_empty; + if (pgp) { - pgpcert_t *pgpcert = malloc_thing(pgpcert_t); - *pgpcert = pgpcert_empty; - if (parse_pgp(chunk_clone(blob), pgpcert)) - { - cert_t *cert = malloc_thing(cert_t); - *cert = cert_empty; - cert->type = CERT_PGP; - cert->u.pgp = pgpcert; - return cert; - } - plog(" error in OpenPGP certificate"); - free_pgpcert(pgpcert); + cert->cert = lib->creds->create(lib->creds, + CRED_CERTIFICATE, CERT_GPG, + BUILD_BLOB_PGP, blob, + BUILD_END); } else { - x509cert_t *x509cert = malloc_thing(x509cert_t); - - *x509cert = empty_x509cert; - x509cert->cert = lib->creds->create(lib->creds, - CRED_CERTIFICATE, CERT_X509, - BUILD_BLOB_ASN1_DER, blob, - BUILD_X509_FLAG, flags, - BUILD_END); - if (x509cert->cert) - { - cert_t *cert = malloc_thing(cert_t); - - *cert = cert_empty; - cert->type = CERT_X509_SIGNATURE; - cert->u.x509 = x509cert; - return cert; - } - plog(" error in X.509 certificate"); - free_x509cert(x509cert); + cert->cert = lib->creds->create(lib->creds, + CRED_CERTIFICATE, CERT_X509, + BUILD_BLOB_ASN1_DER, blob, + BUILD_X509_FLAG, flags, + BUILD_END); + } + if (cert->cert) + { + return cert; } + plog(" error in X.509 certificate"); + cert_free(cert); } return NULL; } |