Add support for pkcs11 URIs in TLS client key/certificate
authorAnton Gerasimov <anton@advancedtelematic.com>
Mon, 18 Sep 2017 14:29:27 +0000 (16:29 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 19 Sep 2017 20:30:22 +0000 (20:30 +0000)
Closes: #1183
Approved by: cgwalters

src/libostree/ostree-fetcher-curl.c

index e3fd1a1258c1100e116a76462746057b8d594820..c22141ec6002605ebdef58aa11d294cb2135d682 100644 (file)
@@ -747,6 +747,24 @@ initiate_next_curl_request (FetcherRequest *req,
 
   if (self->tls_client_cert_path)
     {
+      /* Support for pkcs11:
+       * https://github.com/ostreedev/ostree/pull/1183
+       * This will be used by https://github.com/advancedtelematic/aktualizr
+       * at least to fetch certificates.  No test coverage at the moment
+       * though. See https://gitlab.com/gnutls/gnutls/tree/master/tests/pkcs11
+       * and https://github.com/opendnssec/SoftHSMv2 and
+       * https://github.com/p11-glue/p11-kit/tree/master/p11-kit for
+       * possible ideas there.
+       */
+      if (g_str_has_prefix (self->tls_client_key_path, "pkcs11:"))
+        {
+          curl_easy_setopt (req->easy, CURLOPT_SSLENGINE, "pkcs11");
+          curl_easy_setopt (req->easy, CURLOPT_SSLENGINE_DEFAULT, 1L);
+          curl_easy_setopt (req->easy, CURLOPT_SSLKEYTYPE, "ENG");
+        }
+      if (g_str_has_prefix (self->tls_client_cert_path, "pkcs11:"))
+        curl_easy_setopt (req->easy, CURLOPT_SSLCERTTYPE, "ENG");
+
       curl_easy_setopt (req->easy, CURLOPT_SSLCERT, self->tls_client_cert_path);
       curl_easy_setopt (req->easy, CURLOPT_SSLKEY, self->tls_client_key_path);
     }