Skip to content

Commit

Permalink
Use OpenSSL TPM2 engine
Browse files Browse the repository at this point in the history
We should look at whether we want to do this natively (probably not; we
should rely on the OpenSSL STORE mechanism instead), and we should
definitely look at how we're going to do it for GnuTLS. But this is a
start...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Sep 27, 2018
1 parent 318d577 commit 7edab6c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions openssl.c
Expand Up @@ -615,7 +615,8 @@ static int load_pkcs12_certificate(struct openconnect_info *vpninfo, PKCS12 *p12
}

#ifdef HAVE_ENGINE
static int load_tpm_certificate(struct openconnect_info *vpninfo)
static int load_tpm_certificate(struct openconnect_info *vpninfo,
const char *engine)
{
ENGINE *e;
EVP_PKEY *key;
Expand All @@ -624,7 +625,7 @@ static int load_tpm_certificate(struct openconnect_info *vpninfo)

ENGINE_load_builtin_engines();

e = ENGINE_by_id("tpm");
e = ENGINE_by_id(engine);
if (!e) {
vpn_progress(vpninfo, PRG_ERR, _("Can't load TPM engine.\n"));
openconnect_report_ssl_errors(vpninfo);
Expand Down Expand Up @@ -673,7 +674,8 @@ static int load_tpm_certificate(struct openconnect_info *vpninfo)
return ret;
}
#else
static int load_tpm_certificate(struct openconnect_info *vpninfo)
static int load_tpm_certificate(struct openconnect_info *vpninfo,
const char *engine)
{
vpn_progress(vpninfo, PRG_ERR,
_("This version of OpenConnect was built without TPM support\n"));
Expand Down Expand Up @@ -946,7 +948,10 @@ static int load_certificate(struct openconnect_info *vpninfo)
while (fgets(buf, 255, f)) {
if (!strcmp(buf, "-----BEGIN TSS KEY BLOB-----\n")) {
fclose(f);
return load_tpm_certificate(vpninfo);
return load_tpm_certificate(vpninfo, "tpm");
} else if (!strcmp(buf, "-----BEGIN TSS2 KEY BLOB-----\n")) {
fclose(f);
return load_tpm_certificate(vpninfo, "tpm2");
} else if (!strcmp(buf, "-----BEGIN RSA PRIVATE KEY-----\n") ||
!strcmp(buf, "-----BEGIN DSA PRIVATE KEY-----\n") ||
!strcmp(buf, "-----BEGIN EC PRIVATE KEY-----\n") ||
Expand Down

0 comments on commit 7edab6c

Please sign in to comment.