/* * fetch an ASN.1 blob coded in PEM or DER format from a URL */ static err_t fetch_asn1_blob(char *url, chunk_t *blob) { err_t ugh = NULL; if (strlen(url) >= 4 && strncasecmp(url, "ldap", 4) == 0) { ugh = fetch_ldap_url(url, blob); } else { ugh = fetch_curl(url, blob); } if (ugh != NULL) return ugh; if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" fetched blob coded in DER format") ) } else { bool pgp = FALSE; ugh = pemtobin(blob, NULL, "", &pgp); if (ugh == NULL) { if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" fetched blob coded in PEM format") ) } else { ugh = "blob coded in unknown format"; pfree(blob->ptr); } } else { pfree(blob->ptr); } }
openswan_log(" loaded %s file '%s' (%d bytes)", type, filename, bytes); } *pgp = FALSE; /* try DER format */ if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" file coded in DER format"); ) return TRUE; } /* try PEM format */ ugh = pemtobin(blob, pass, filename, pgp); if (ugh == NULL) { if (*pgp) { DBG(DBG_PARSING, DBG_log(" file coded in armored PGP format"); ) return TRUE; } if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" file coded in PEM format"); )
fclose(fd); if (verbose) libreswan_log(" loaded %s file '%s' (%zu bytes)", type, filename, bytes); /* try DER format */ if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" file coded in DER format"); ); return TRUE; } /* try PEM format */ ugh = pemtobin(blob); if (ugh == NULL) { if (is_asn1(*blob)) { DBG(DBG_PARSING, DBG_log(" file coded in PEM format"); ); return TRUE; } ugh = "file coded in unknown format, discarded"; } /* a conversion error has occured */ if (verbose) libreswan_log(" %s", ugh); pfree(blob->ptr);