Support loading cacert certificates in ipsec.conf ca sections from smartcard
This commit is contained in:
@@ -168,9 +168,24 @@ static certificate_t *load_from_smartcard(smartcard_format_t format,
|
||||
METHOD(stroke_cred_t, load_ca, certificate_t*,
|
||||
private_stroke_cred_t *this, char *filename)
|
||||
{
|
||||
certificate_t *cert;
|
||||
certificate_t *cert = NULL;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (strneq(filename, "%smartcard", strlen("%smartcard")))
|
||||
{
|
||||
smartcard_format_t format;
|
||||
char module[BUF_LEN], keyid[BUF_LEN];
|
||||
u_int slot;
|
||||
|
||||
format = parse_smartcard(filename, &slot, module, keyid);
|
||||
if (format != SC_FORMAT_INVALID)
|
||||
{
|
||||
cert = (certificate_t*)load_from_smartcard(format,
|
||||
slot, module, keyid, CRED_CERTIFICATE, CERT_X509);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*filename == '/')
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s", filename);
|
||||
@@ -195,6 +210,7 @@ METHOD(stroke_cred_t, load_ca, certificate_t*,
|
||||
BUILD_FROM_FILE, path,
|
||||
BUILD_END);
|
||||
}
|
||||
}
|
||||
if (cert)
|
||||
{
|
||||
x509_t *x509 = (x509_t*)cert;
|
||||
@@ -206,6 +222,8 @@ METHOD(stroke_cred_t, load_ca, certificate_t*,
|
||||
cert->destroy(cert);
|
||||
return NULL;
|
||||
}
|
||||
DBG1(DBG_CFG, " loaded ca certificate \"%Y\" from '%s",
|
||||
cert->get_subject(cert), filename);
|
||||
return this->creds->add_cert_ref(this->creds, TRUE, cert);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user