|
|
ecf709 |
From d35f47a4e50feeb2b54c1621d0c2f5b15cd275eb Mon Sep 17 00:00:00 2001
|
|
|
ecf709 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
ecf709 |
Date: Tue, 28 Feb 2017 11:47:32 +0100
|
|
|
ecf709 |
Subject: [PATCH 85/90] secrets: allow to configure certificate check
|
|
|
ecf709 |
|
|
|
ecf709 |
Some users may want to use TLS with unverified peer (for example if
|
|
|
ecf709 |
they use self-signed certificate) or if unverified hostname (if
|
|
|
ecf709 |
certificate hostname does not match with the real hostname). On the
|
|
|
ecf709 |
other side it may be useful to point to a directory containing custom
|
|
|
ecf709 |
certificate authorities.
|
|
|
ecf709 |
|
|
|
ecf709 |
This patch add three new options to secrets responder:
|
|
|
ecf709 |
verify_peer => peer's certificate must be valid
|
|
|
ecf709 |
verify_host => hostnames must match
|
|
|
ecf709 |
capath => path to directory containing CA certs
|
|
|
ecf709 |
cacert => ca certificate
|
|
|
ecf709 |
cert => client certificate
|
|
|
ecf709 |
key => client private key
|
|
|
ecf709 |
|
|
|
ecf709 |
Resolves:
|
|
|
ecf709 |
https://pagure.io/SSSD/sssd/issue/3192
|
|
|
ecf709 |
|
|
|
ecf709 |
Reviewed-by: Simo Sorce <simo@redhat.com>
|
|
|
ecf709 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
ecf709 |
(cherry picked from commit 720e1a5b95a953a0f1c8315bbb7c9c1edf9fb417)
|
|
|
ecf709 |
---
|
|
|
ecf709 |
src/config/SSSDConfig/__init__.py.in | 6 +++
|
|
|
ecf709 |
src/config/cfg_rules.ini | 6 +++
|
|
|
ecf709 |
src/config/etc/sssd.api.conf | 6 +++
|
|
|
ecf709 |
src/man/sssd-secrets.5.xml | 76 ++++++++++++++++++++++++++++++++++++
|
|
|
ecf709 |
src/responder/secrets/proxy.c | 55 ++++++++++++++++++++++++++
|
|
|
ecf709 |
5 files changed, 149 insertions(+)
|
|
|
ecf709 |
|
|
|
ecf709 |
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
|
|
|
ecf709 |
index 211338778e81c1c60ffb3cdbc67c9619343d7798..75515ab5c68822538728900482296b9159e1547e 100644
|
|
|
ecf709 |
--- a/src/config/SSSDConfig/__init__.py.in
|
|
|
ecf709 |
+++ b/src/config/SSSDConfig/__init__.py.in
|
|
|
ecf709 |
@@ -137,6 +137,12 @@ option_strings = {
|
|
|
ecf709 |
'forward_headers': _('The list of the headers to forward to the Custodia server together with the request'),
|
|
|
ecf709 |
'username': _('The username to use when authenticating to a Custodia server using basic_auth'),
|
|
|
ecf709 |
'password': _('The password to use when authenticating to a Custodia server using basic_auth'),
|
|
|
ecf709 |
+ 'verify_peer': _('If true peer\'s certificate is verified if proxy_url uses https protocol'),
|
|
|
ecf709 |
+ 'verify_host': _('If false peer\'s certificate may contain different hostname then proxy_url when https protocol is used'),
|
|
|
ecf709 |
+ 'capath': _('Path to directory where certificate authority certificates are stored'),
|
|
|
ecf709 |
+ 'cacert': _('Path to file containing server\'s CA certificate'),
|
|
|
ecf709 |
+ 'cert': _('Path to file containing client\'s certificate'),
|
|
|
ecf709 |
+ 'key': _('Path to file containing client\'s private key'),
|
|
|
ecf709 |
|
|
|
ecf709 |
# [provider]
|
|
|
ecf709 |
'id_provider' : _('Identity provider'),
|
|
|
ecf709 |
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
|
|
|
ecf709 |
index 1a749db754cedd87f263f7ae596d6f8238bb4357..e47ff33242d6a9e5979fe0eb8eea14c2af28685a 100644
|
|
|
ecf709 |
--- a/src/config/cfg_rules.ini
|
|
|
ecf709 |
+++ b/src/config/cfg_rules.ini
|
|
|
ecf709 |
@@ -265,6 +265,12 @@ option = auth_header_value
|
|
|
ecf709 |
option = forward_headers
|
|
|
ecf709 |
option = username
|
|
|
ecf709 |
option = password
|
|
|
ecf709 |
+option = verify_peer
|
|
|
ecf709 |
+option = verify_host
|
|
|
ecf709 |
+option = capath
|
|
|
ecf709 |
+option = cacert
|
|
|
ecf709 |
+option = cert
|
|
|
ecf709 |
+option = key
|
|
|
ecf709 |
|
|
|
ecf709 |
# KCM responder
|
|
|
ecf709 |
[rule/allowed_kcm_options]
|
|
|
ecf709 |
diff --git a/src/config/etc/sssd.api.conf b/src/config/etc/sssd.api.conf
|
|
|
ecf709 |
index a1a0c2992925a4c7df86832117eec2a0cf7894c9..f86589ecefa0b9e046aba781ded107f8e94395d6 100644
|
|
|
ecf709 |
--- a/src/config/etc/sssd.api.conf
|
|
|
ecf709 |
+++ b/src/config/etc/sssd.api.conf
|
|
|
ecf709 |
@@ -114,6 +114,12 @@ auth_header_value = str, None, false
|
|
|
ecf709 |
forward_headers = list, None, false
|
|
|
ecf709 |
username = str, None, false
|
|
|
ecf709 |
password = str, None, false
|
|
|
ecf709 |
+verify_peer = bool, None, false
|
|
|
ecf709 |
+verify_host = bool, None, false
|
|
|
ecf709 |
+capath = str, None, false
|
|
|
ecf709 |
+cacert = str, None, false
|
|
|
ecf709 |
+cert = str, None, false
|
|
|
ecf709 |
+key = str, None, false
|
|
|
ecf709 |
|
|
|
ecf709 |
[provider]
|
|
|
ecf709 |
#Available provider types
|
|
|
ecf709 |
diff --git a/src/man/sssd-secrets.5.xml b/src/man/sssd-secrets.5.xml
|
|
|
ecf709 |
index 80e9c405921e1fb46a3d172d9873deebfa5ed2ce..44a86c3fb56a8bdebebd01e9f49ad171986282a4 100644
|
|
|
ecf709 |
--- a/src/man/sssd-secrets.5.xml
|
|
|
ecf709 |
+++ b/src/man/sssd-secrets.5.xml
|
|
|
ecf709 |
@@ -273,6 +273,82 @@ systemctl enable sssd-secrets.service
|
|
|
ecf709 |
</para>
|
|
|
ecf709 |
</listitem>
|
|
|
ecf709 |
</varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>verify_peer (boolean)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Whether peer's certificate should be verified and valid
|
|
|
ecf709 |
+ if HTTPS protocol is used with the proxy provider.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: true
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>verify_host (boolean)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Whether peer's hostname must match with hostname in
|
|
|
ecf709 |
+ its certificate if HTTPS protocol is used with the
|
|
|
ecf709 |
+ proxy provider.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: true
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>capath (string)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Path to directory containing stored certificate authority
|
|
|
ecf709 |
+ certificates. System default path is used if this option is
|
|
|
ecf709 |
+ not set.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: not set
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>cacert (string)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Path to file containing server's certificate authority
|
|
|
ecf709 |
+ certificate. If this option is not set then the CA's
|
|
|
ecf709 |
+ certificate is looked up in <quote>capath</quote>.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: not set
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>cert (string)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Path to file containing client's certificate if required
|
|
|
ecf709 |
+ by the server. This file may also contain private key or
|
|
|
ecf709 |
+ the private key may be in separate file set with
|
|
|
ecf709 |
+ <quote>key</quote>.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: not set
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
+ <varlistentry>
|
|
|
ecf709 |
+ <term>key (string)</term>
|
|
|
ecf709 |
+ <listitem>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Path to file containing client's private key.
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ <para>
|
|
|
ecf709 |
+ Default: not set
|
|
|
ecf709 |
+ </para>
|
|
|
ecf709 |
+ </listitem>
|
|
|
ecf709 |
+ </varlistentry>
|
|
|
ecf709 |
</variablelist>
|
|
|
ecf709 |
</refsect1>
|
|
|
ecf709 |
<refsect1 id='restapi'>
|
|
|
ecf709 |
diff --git a/src/responder/secrets/proxy.c b/src/responder/secrets/proxy.c
|
|
|
ecf709 |
index 3c495716010ac468c9e2f1fb6356529a8dbdc614..240a1de1e431d511a1eca24d8b463c37ba893e7b 100644
|
|
|
ecf709 |
--- a/src/responder/secrets/proxy.c
|
|
|
ecf709 |
+++ b/src/responder/secrets/proxy.c
|
|
|
ecf709 |
@@ -59,6 +59,13 @@ struct proxy_cfg {
|
|
|
ecf709 |
struct pat_basic_auth basic;
|
|
|
ecf709 |
struct pat_header header;
|
|
|
ecf709 |
} auth;
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ char *key;
|
|
|
ecf709 |
+ char *cert;
|
|
|
ecf709 |
+ char *cacert;
|
|
|
ecf709 |
+ char *capath;
|
|
|
ecf709 |
+ bool verify_peer;
|
|
|
ecf709 |
+ bool verify_host;
|
|
|
ecf709 |
};
|
|
|
ecf709 |
|
|
|
ecf709 |
static int proxy_get_config_string(struct proxy_context *pctx,
|
|
|
ecf709 |
@@ -129,6 +136,38 @@ static int proxy_sec_get_cfg(struct proxy_context *pctx,
|
|
|
ecf709 |
}
|
|
|
ecf709 |
}
|
|
|
ecf709 |
|
|
|
ecf709 |
+ ret = confdb_get_bool(pctx->cdb, secreq->cfg_section, "verify_peer",
|
|
|
ecf709 |
+ true, &cfg->verify_peer);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "verify_peer: %s\n",
|
|
|
ecf709 |
+ (&cfg->verify_peer ? "true" : "false"));
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ ret = confdb_get_bool(pctx->cdb, secreq->cfg_section, "verify_host",
|
|
|
ecf709 |
+ true, &cfg->verify_host);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "verify_host: %s\n",
|
|
|
ecf709 |
+ (&cfg->verify_host ? "true" : "false"));
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ ret = proxy_get_config_string(pctx, cfg, false, secreq,
|
|
|
ecf709 |
+ "capath", &cfg->capath);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "capath: %s\n", cfg->capath);
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ ret = proxy_get_config_string(pctx, cfg, false, secreq,
|
|
|
ecf709 |
+ "cacert", &cfg->cacert);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "cacert: %s\n", cfg->cacert);
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ ret = proxy_get_config_string(pctx, cfg, false, secreq,
|
|
|
ecf709 |
+ "cert", &cfg->cert);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "cert: %s\n", cfg->cert);
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ ret = proxy_get_config_string(pctx, cfg, false, secreq,
|
|
|
ecf709 |
+ "key", &cfg->key);
|
|
|
ecf709 |
+ if (ret) goto done;
|
|
|
ecf709 |
+ DEBUG(SSSDBG_CONF_SETTINGS, "key: %s\n", cfg->key);
|
|
|
ecf709 |
+
|
|
|
ecf709 |
ret = confdb_get_string_as_list(pctx->cdb, cfg, secreq->cfg_section,
|
|
|
ecf709 |
"forward_headers", &cfg->fwd_headers);
|
|
|
ecf709 |
if ((ret != 0) && (ret != ENOENT)) goto done;
|
|
|
ecf709 |
@@ -385,6 +424,22 @@ static errno_t proxy_http_create_request(TALLOC_CTX *mem_ctx,
|
|
|
ecf709 |
goto done;
|
|
|
ecf709 |
}
|
|
|
ecf709 |
|
|
|
ecf709 |
+ /* Set TLS settings to verify peer.
|
|
|
ecf709 |
+ * This has no effect for HTTP protocol so we can set it anyway. */
|
|
|
ecf709 |
+ ret = tcurl_req_verify_peer(tcurl_req, pcfg->capath, pcfg->cacert,
|
|
|
ecf709 |
+ pcfg->verify_peer, pcfg->verify_host);
|
|
|
ecf709 |
+ if (ret != EOK) {
|
|
|
ecf709 |
+ goto done;
|
|
|
ecf709 |
+ }
|
|
|
ecf709 |
+
|
|
|
ecf709 |
+ /* Set client's certificate if required. */
|
|
|
ecf709 |
+ if (pcfg->cert != NULL) {
|
|
|
ecf709 |
+ ret = tcurl_req_set_client_cert(tcurl_req, pcfg->cert, pcfg->key);
|
|
|
ecf709 |
+ if (ret != EOK) {
|
|
|
ecf709 |
+ goto done;
|
|
|
ecf709 |
+ }
|
|
|
ecf709 |
+ }
|
|
|
ecf709 |
+
|
|
|
ecf709 |
talloc_steal(tcurl_req, body);
|
|
|
ecf709 |
*_tcurl_req = talloc_steal(mem_ctx, tcurl_req);
|
|
|
ecf709 |
|
|
|
ecf709 |
--
|
|
|
ecf709 |
2.9.3
|
|
|
ecf709 |
|