mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
client install: fix client PKINIT configuration
Set `pkinit_anchors` in `krb5.conf` to a CA certificate bundle of CAs trusted to issue KDC certificates rather than `/etc/ipa/ca.crt`. Set `pkinit_pool` in `krb5.conf` to a CA certificate bundle of all CAs known to IPA. Make sure both bundles are exported in all installation code paths. https://pagure.io/freeipa/issue/6831 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com> Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
01a7416d30
commit
11b8a34346
@@ -101,4 +101,5 @@ EXTRA_DIST = \
|
||||
|
||||
install-data-hook:
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(IPA_SYSCONF_DIR)/nssdb
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/lib/ipa-client/pki
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/lib/ipa-client/sysrestore
|
||||
|
||||
@@ -1101,6 +1101,15 @@ if [ $1 -gt 1 ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $restore -ge 2 ]; then
|
||||
if grep -E -q '\s*pkinit_anchors = FILE:/etc/ipa/ca.crt$' /etc/krb5.conf 2>/dev/null; then
|
||||
sed -E 's|(\s*)pkinit_anchors = FILE:/etc/ipa/ca.crt$|\1pkinit_anchors = FILE:/var/lib/ipa-client/pki/kdc-ca-bundle.pem\n\1pkinit_pool = FILE:/var/lib/ipa-client/pki/ca-bundle.pem|' /etc/krb5.conf >/etc/krb5.conf.ipanew
|
||||
mv -Z /etc/krb5.conf.ipanew /etc/krb5.conf
|
||||
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/kdc-ca-bundle.pem
|
||||
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/ca-bundle.pem
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f '/etc/sysconfig/ntpd' -a $restore -ge 2 ]; then
|
||||
if grep -E -q 'OPTIONS=.*-u ntp:ntp' /etc/sysconfig/ntpd 2>/dev/null; then
|
||||
sed -r '/OPTIONS=/ { s/\s+-u ntp:ntp\s+/ /; s/\s*-u ntp:ntp\s*// }' /etc/sysconfig/ntpd >/etc/sysconfig/ntpd.ipanew
|
||||
@@ -1473,6 +1482,7 @@ fi
|
||||
%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/pwdfile.txt
|
||||
%ghost %config(noreplace) %{_sysconfdir}/pki/ca-trust/source/ipa.p11-kit
|
||||
%dir %{_localstatedir}/lib/ipa-client
|
||||
%dir %{_localstatedir}/lib/ipa-client/pki
|
||||
%dir %{_localstatedir}/lib/ipa-client/sysrestore
|
||||
%{_mandir}/man5/default.conf.5*
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ $OTHER_LIBDEFAULTS
|
||||
master_kdc = $FQDN:88
|
||||
admin_server = $FQDN:749
|
||||
default_domain = $DOMAIN
|
||||
pkinit_anchors = FILE:/etc/ipa/ca.crt
|
||||
pkinit_anchors = FILE:$KDC_CA_BUNDLE_PEM
|
||||
pkinit_pool = FILE:$CA_BUNDLE_PEM
|
||||
}
|
||||
|
||||
[domain_realm]
|
||||
|
||||
@@ -710,7 +710,11 @@ def configure_krb5_conf(
|
||||
kropts.append(krbconf.setOption('default_domain', cli_domain))
|
||||
|
||||
kropts.append(
|
||||
krbconf.setOption('pkinit_anchors', 'FILE:%s' % paths.IPA_CA_CRT))
|
||||
krbconf.setOption('pkinit_anchors',
|
||||
'FILE:%s' % paths.KDC_CA_BUNDLE_PEM))
|
||||
kropts.append(
|
||||
krbconf.setOption('pkinit_pool',
|
||||
'FILE:%s' % paths.CA_BUNDLE_PEM))
|
||||
ropts = [{
|
||||
'name': cli_realm,
|
||||
'type': 'subsection',
|
||||
@@ -2770,6 +2774,13 @@ def _install(options):
|
||||
ca_certs_trust = [(c, n, certstore.key_policy_to_trust_flags(t, True, u))
|
||||
for (c, n, t, u) in ca_certs]
|
||||
|
||||
x509.write_certificate_list(
|
||||
[c for c, n, t, u in ca_certs if t is not False],
|
||||
paths.KDC_CA_BUNDLE_PEM)
|
||||
x509.write_certificate_list(
|
||||
[c for c, n, t, u in ca_certs if t is not False],
|
||||
paths.CA_BUNDLE_PEM)
|
||||
|
||||
# Add the CA certificates to the IPA NSS database
|
||||
root_logger.debug("Adding CA certificates to the IPA NSS database.")
|
||||
ipa_db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
|
||||
@@ -3317,6 +3328,8 @@ def uninstall(options):
|
||||
|
||||
# Remove the CA cert
|
||||
remove_file(paths.IPA_CA_CRT)
|
||||
remove_file(paths.KDC_CA_BUNDLE_PEM)
|
||||
remove_file(paths.CA_BUNDLE_PEM)
|
||||
|
||||
root_logger.info("Client uninstall complete.")
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ class CertUpdate(admintool.AdminTool):
|
||||
|
||||
def update_client(self, certs):
|
||||
self.update_file(paths.IPA_CA_CRT, certs)
|
||||
self.update_file(paths.KDC_CA_BUNDLE_PEM, certs)
|
||||
self.update_file(paths.CA_BUNDLE_PEM, certs)
|
||||
|
||||
ipa_db = certdb.NSSDatabase(api.env.nss_dir)
|
||||
|
||||
|
||||
@@ -333,6 +333,8 @@ class BasePathNamespace(object):
|
||||
VAR_RUN_DIRSRV_DIR = "/var/run/dirsrv"
|
||||
IPA_CCACHES = "/var/run/ipa/ccaches"
|
||||
HTTP_CCACHE = "/var/lib/ipa/gssproxy/http.ccache"
|
||||
CA_BUNDLE_PEM = "/var/lib/ipa-client/pki/ca-bundle.pem"
|
||||
KDC_CA_BUNDLE_PEM = "/var/lib/ipa-client/pki/kdc-ca-bundle.pem"
|
||||
IPA_RENEWAL_LOCK = "/var/run/ipa/renewal.lock"
|
||||
SVC_LIST_FILE = "/var/run/ipa/services.list"
|
||||
KRB5CC_SAMBA = "/var/run/samba/krb5cc_samba"
|
||||
|
||||
@@ -794,10 +794,13 @@ class CAInstance(DogtagInstance):
|
||||
certlist = x509.pkcs7_to_pems(data, x509.DER)
|
||||
|
||||
# We have all the certificates in certlist, write them to a PEM file
|
||||
with open(paths.IPA_CA_CRT, 'w') as ipaca_pem:
|
||||
for cert in certlist:
|
||||
ipaca_pem.write(cert)
|
||||
ipaca_pem.write('\n')
|
||||
for path in [paths.IPA_CA_CRT,
|
||||
paths.KDC_CA_BUNDLE_PEM,
|
||||
paths.CA_BUNDLE_PEM]:
|
||||
with open(path, 'w') as ipaca_pem:
|
||||
for cert in certlist:
|
||||
ipaca_pem.write(cert)
|
||||
ipaca_pem.write('\n')
|
||||
|
||||
def __request_ra_certificate(self):
|
||||
# create a temp file storing the pwd
|
||||
|
||||
@@ -150,6 +150,8 @@ class Backup(admintool.AdminTool):
|
||||
paths.SSHD_CONFIG,
|
||||
paths.SSH_CONFIG,
|
||||
paths.KRB5_CONF,
|
||||
paths.KDC_CA_BUNDLE_PEM,
|
||||
paths.CA_BUNDLE_PEM,
|
||||
paths.IPA_CA_CRT,
|
||||
paths.IPA_DEFAULT_CONF,
|
||||
paths.DS_KEYTAB,
|
||||
|
||||
@@ -261,7 +261,9 @@ class KrbInstance(service.Service):
|
||||
KRB5KDC_KADM5_KEYTAB=paths.KRB5KDC_KADM5_KEYTAB,
|
||||
KDC_CERT=paths.KDC_CERT,
|
||||
KDC_KEY=paths.KDC_KEY,
|
||||
CACERT_PEM=paths.CACERT_PEM)
|
||||
CACERT_PEM=paths.CACERT_PEM,
|
||||
KDC_CA_BUNDLE_PEM=paths.KDC_CA_BUNDLE_PEM,
|
||||
CA_BUNDLE_PEM=paths.CA_BUNDLE_PEM)
|
||||
|
||||
# IPA server/KDC is not a subdomain of default domain
|
||||
# Proper domain-realm mapping needs to be specified
|
||||
|
||||
@@ -796,6 +796,16 @@ def install(installer):
|
||||
x509.write_certificate(http_ca_cert, paths.IPA_CA_CRT)
|
||||
os.chmod(paths.IPA_CA_CRT, 0o444)
|
||||
|
||||
if not options.no_pkinit:
|
||||
x509.write_certificate(http_ca_cert, paths.KDC_CA_BUNDLE_PEM)
|
||||
else:
|
||||
with open(paths.KDC_CA_BUNDLE_PEM, 'w'):
|
||||
pass
|
||||
os.chmod(paths.KDC_CA_BUNDLE_PEM, 0o444)
|
||||
|
||||
x509.write_certificate(http_ca_cert, paths.CA_BUNDLE_PEM)
|
||||
os.chmod(paths.CA_BUNDLE_PEM, 0o444)
|
||||
|
||||
# we now need to enable ssl on the ds
|
||||
ds.enable_ssl()
|
||||
|
||||
|
||||
@@ -1390,6 +1390,10 @@ def install(installer):
|
||||
|
||||
# Update and istall updated CA file
|
||||
cafile = install_ca_cert(conn, api.env.basedn, api.env.realm, cafile)
|
||||
install_ca_cert(conn, api.env.basedn, api.env.realm, cafile,
|
||||
destfile=paths.KDC_CA_BUNDLE_PEM)
|
||||
install_ca_cert(conn, api.env.basedn, api.env.realm, cafile,
|
||||
destfile=paths.CA_BUNDLE_PEM)
|
||||
|
||||
# Configure dirsrv
|
||||
ds = install_replica_ds(config, options, ca_enabled,
|
||||
|
||||
@@ -1831,7 +1831,9 @@ def upgrade_configuration():
|
||||
KRB5KDC_KADM5_KEYTAB=paths.KRB5KDC_KADM5_KEYTAB,
|
||||
KDC_CERT=paths.KDC_CERT,
|
||||
KDC_KEY=paths.KDC_KEY,
|
||||
CACERT_PEM=paths.CACERT_PEM)
|
||||
CACERT_PEM=paths.CACERT_PEM,
|
||||
KDC_CA_BUNDLE_PEM=paths.KDC_CA_BUNDLE_PEM,
|
||||
CA_BUNDLE_PEM=paths.CA_BUNDLE_PEM)
|
||||
krb.add_anonymous_principal()
|
||||
setup_pkinit(krb)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user