freeipa / freeipa-container

FreeIPA server in containers — images at https://quay.io/repository/freeipa/freeipa-server?tab=tags
https://quay.io/repository/freeipa/freeipa-server?tab=tags
Apache License 2.0
602 stars 258 forks source link

Certificate not found: caSigningCert cert-pki-ca #509

Closed microbioticajon closed 1 year ago

microbioticajon commented 1 year ago

Hi Guys,

Im having a bit of trouble getting a server running and am hoping someone can look at my configuration and tell me where I'm going wrong.

OS: Amazon Linux 2 Image: almalinux-9-4.10.0 (and others) Host: EC2 A-record: freeipa.my.domain (AWS Route53 private hosted zone) Command:

sudo docker run 
--name freeipa-server-container 
--read-only --restart unless-stopped 
--log-driver awslogs --log-opt awslogs-region=eu-west-2 --log-opt awslogs-group=/ecs/dev-freeipa
-v /sys/fs/cgroup:/sys/fs/cgroup:ro 
-v /mnt/ipa_data:/data:Z 
-h freeipa.my.domain 
--sysctl net.ipv6.conf.all.disable_ipv6=0
-e PASSWORD=12345678... 
-e IPA_SERVER_IP=172....
-e DEBUG_TRACE=1 
-p 80:80 
-p 443:443 
-p 389:389 
-p 636:636 
-p 53:53 
-p 53:53/udp 
-p 88:88 
-p 88:88/udp 
-p 464:464 
-p 464:464/udp 
freeipa/freeipa-server:almalinux-9-4.10.0 
-d -U 
-r MY.DOMAIN
--domain my.domain 
--no-ntp

Install Log at point of error:

...
INFO: Storing cert and request for signing
INFO: Importing signing cert into NSS database
DEBUG: NSSDatabase.add_cert(caSigningCert cert-pki-ca)
DEBUG: Command: pki -d /etc/pki/pki-tomcat/alias -C /tmp/tmpol7971sr/password.txt nss-cert-import --format PEM --debug caSigningCert cert-pki-ca
INFO: Initializing NSS
INFO: Logging into internal token
INFO: Using internal token
FINE: NSSDatabase: Storing password into /tmp/nss-password-6636204075005843057.txt
FINE: NSSDatabase: Command: certutil -A -d /etc/pki/pki-tomcat/alias -f /tmp/nss-password-6636204075005843057.txt -a -n "caSigningCert cert-pki-ca" -t ,, -i /tmp/nss-cert-13850102911832823951.crt
INFO: Initializing CA

Failed to configure CA instance
See the installation logs and the following files/directories for more information:
  /var/log/pki/pki-tomcat
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/ipaserver/install/service.py", line 686, in start_creation
    run_step(full_msg, method)
  File "/usr/lib/python3.9/site-packages/ipaserver/install/service.py", line 672, in run_step
    method()
  File "/usr/lib/python3.9/site-packages/ipaserver/install/cainstance.py", line 646, in __spawn_instance
    DogtagInstance.spawn_instance(
  File "/usr/lib/python3.9/site-packages/ipaserver/install/dogtaginstance.py", line 227, in spawn_instance
    self.handle_setup_error(e)
  File "/usr/lib/python3.9/site-packages/ipaserver/install/dogtaginstance.py", line 604, in handle_setup_error
    raise RuntimeError(
RuntimeError: CA configuration failed.

sudo less /mnt/ipa_data/var/log/pki/pki-tomcat/ca/debug.2023-01-09.log:

...
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-4] INFO: CAInstallerService: - cert ID: 0x1
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: Creating cert
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - request ID: 0x1
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - request type: pkcs10
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - subject: CN=Certificate Authority,O=MY.DOMAIN
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - cert ID: 0x1
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - cert type: selfsign
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - profile: caCert.profile
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - key algorithm: SHA256withRSA
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - token: internal
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - key ID: 0x65dc7336f95244a23fa2dc7426671b15362671f4
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - issuer: CN=Certificate Authority,O=MY.DOMAIN
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: - signing algorithm: SHA256withRSA
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: Loading /var/lib/pki/pki-tomcat/ca/conf/caCert.profile
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: CAInstallerService: Cert info:
[
  Version: V3
  Subject: CN=Certificate Authority,O=MY.DOMAIN
  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11

  Key:  algorithm = RSA, unparsed keybits = 
30 82 01 8A 02 82 01 81 00 DB A8 A6 AB E1 DF .......

  Validity: [From: Mon Jan 09 23:14:23 UTC 2023,
               To: Mon Jan 09 23:14:23 UTC 2023]
  Issuer: CN=Certificate Authority,O=MY.DOMAIN
  SerialNumber: [    01]

]
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: LDAPSession: Retrieving cn=1,ou=ca, ou=requests,o=ipaca
2023-01-09 23:14:23 [https-jsse-nio-8443-exec-5] INFO: LDAPSession: Modifying cn=1,ou=ca, ou=requests,o=ipaca
2023-01-09 23:14:27 [https-jsse-nio-8443-exec-7] INFO: CAInstallerService: Initializing subsystem
2023-01-09 23:14:27 [https-jsse-nio-8443-exec-7] INFO: CertificateAuthority: Initializing cert signing unit
2023-01-09 23:14:27 [https-jsse-nio-8443-exec-7] SEVERE: Object certificate not found. Error Certificate not found: caSigningCert cert-pki-ca: Certificate not found: caSigningCert cert-pki-ca
Certificate not found: caSigningCert cert-pki-ca: Certificate not found: caSigningCert cert-pki-ca
 at com.netscape.ca.CASigningUnit.init(CASigningUnit.java:95)
        at com.netscape.ca.CertificateAuthority.initCertSigningUnit(CertificateAuthority.java:1303)
        at org.dogtagpki.server.ca.rest.CAInstallerService.initSubsystem(CAInstallerService.java:321)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
        ...

Im not providing any certificates at the moment and suspect this is where things are breaking down. Any help would be appreciated (apologies in advance if this is an obvious problem...)

adelton commented 1 year ago

I don't see anything suspicious.

Can you try

$ docker='sudo docker' replica=none tests/run-master-and-replica.sh freeipa/freeipa-server:almalinux-9-4.10.0 

and see what it produces?

microbioticajon commented 1 year ago

@adelton Thanks for your quick reply!

The docker logs from docker='sudo docker' replica=none tests/run-master-and-replica.sh freeipa/freeipa-server:almalinux-9-4.10.0:

FreeIPA server is already configured but with different version, volume update.
Wed Jan 11 11:13:28 UTC 2023 /usr/sbin/ipa-server-configure-first upgrade
/etc/resolv.conf /data/etc/resolv.conf.ipa differ: byte 1, line 1
/data/build-id /data-template/build-id differ: byte 1, line 1
FreeIPA server is already configured but with different version, starting upgrade.
+ '[' -n '' ']'
+ output=/dev/null
+ output2=/dev/null
+ /bin/systemctl daemon-reload
+ USERNAME=dirsrv
+ ALLOCATED_UID=389
+ GROUPNAME=dirsrv
+ ALLOCATED_GID=389
+ HOMEDIR=/usr/share/dirsrv
+ getent group dirsrv
+ getent passwd dirsrv
+ sysctl --system
+ true
+ instbase=/etc/dirsrv
+ ninst=0
+ for dir in $instbase/slapd-*
+ echo dir = /etc/dirsrv/slapd-EXAMPLE-TEST
+ '[' '!' -d /etc/dirsrv/slapd-EXAMPLE-TEST ']'
+ case "$dir" in
++ basename /etc/dirsrv/slapd-EXAMPLE-TEST
+ basename=slapd-EXAMPLE-TEST
++ echo slapd-EXAMPLE-TEST
++ sed -e s/slapd-//g
+ inst=dirsrv@EXAMPLE-TEST
+ echo found instance dirsrv@EXAMPLE-TEST - getting status
+ /bin/systemctl -q is-active dirsrv@EXAMPLE-TEST
+ echo instance dirsrv@EXAMPLE-TEST is not running
++ expr 0 + 1
+ ninst=1
+ '[' 1 -eq 0 ']'
+ echo shutting down all instances . . .
+ '[' -f /data/etc/named.conf ']'
++ uname -m
+ PLATFORM=x86_64
+ '[' x86_64 == x86_64 ']'
+ LIBPATH=/usr/lib64
+ read -r PATTERN
+ SEDSCRIPT+='/^\s*dynamic-db/,/};/ {'
+ read -r PATTERN
+ SEDSCRIPT+=
+ read -r PATTERN
+ SEDSCRIPT+='s/\(\s*\)arg\s\+\(["'\'']\)\([a-zA-Z_]\+\s\)/\1\3\2/g;'
+ read -r PATTERN
+ SEDSCRIPT+=
+ read -r PATTERN
+ SEDSCRIPT+='s/^dynamic-db/dyndb/;'
+ read -r PATTERN
+ SEDSCRIPT+=
+ read -r PATTERN
+ SEDSCRIPT+='s@\(dyndb "[^"]\+"\)@\1 "/usr/lib64/bind/ldap.so"@;'
+ read -r PATTERN
+ SEDSCRIPT+='s@\(dyndb '\''[^'\'']\+'\''\)@\1 '\''/usr/lib64/bind/ldap.so'\''@;'
+ read -r PATTERN
+ SEDSCRIPT+=
+ read -r PATTERN
+ SEDSCRIPT+='/\s*library[^;]\+;/d;'
+ read -r PATTERN
+ SEDSCRIPT+='/\s*cache_ttl[^;]\+;/d;'
+ read -r PATTERN
+ SEDSCRIPT+='/\s*psearch[^;]\+;/d;'
+ read -r PATTERN
+ SEDSCRIPT+='/\s*serial_autoincrement[^;]\+;/d;'
+ read -r PATTERN
+ SEDSCRIPT+='/\s*zone_refresh[^;]\+;/d;'
+ read -r PATTERN
+ SEDSCRIPT+='}'
+ read -r PATTERN
+ sed -i.bak -e '/^\s*dynamic-db/,/};/ {s/\(\s*\)arg\s\+\(["'\'']\)\([a-zA-Z_]\+\s\)/\1\3\2/g;s/^dynamic-db/dyndb/;s@\(dyndb "[^"]\+"\)@\1 "/usr/lib64/bind/ldap.so"@;s@\(dyndb '\''[^'\'']\+'\''\)@\1 '\''/usr/lib64/bind/ldap.so'\''@;/\s*library[^;]\+;/d;/\s*cache_ttl[^;]\+;/d;/\s*psearch[^;]\+;/d;/\s*serial_autoincrement[^;]\+;/d;/\s*zone_refresh[^;]\+;/d;}' /data/etc/named.conf
+ test 2 -eq 1
+ test 2 -gt 1
+ /usr/bin/getcert remove-ca -c certmaster
No CA with name "certmaster" found.
+ :
+ test 2 -eq 1
Upgrading IPA:. Estimated time: 1 minute 30 seconds
  [1/9]: saving configuration
  [2/9]: disabling listeners
  [3/9]: enabling DS global lock
  [4/9]: disabling Schema Compat
  [5/9]: starting directory server
  [6/9]: updating schema
  [7/9]: upgrading server
  [8/9]: stopping directory server
  [9/9]: restoring configuration
Done.
Update complete
Upgrading the configuration of the IPA services
[Verifying that root certificate is published]
[Migrate CRL publish directory]
Publish directory already set to new location
[Verifying that KDC configuration is using ipa-kdb backend]
[Fix DS schema file syntax]
[Removing RA cert from DS NSS database]
[Enable sidgen and extdom plugins by default]
[Updating HTTPD service IPA configuration]
[Updating HTTPD service IPA WSGI configuration]
Nothing to do for configure_httpd_wsgi_conf
[Migrating from mod_nss to mod_ssl]
Already migrated to mod_ssl
[Moving HTTPD service keytab to gssproxy]
[Removing self-signed CA]
[Removing Dogtag 9 CA]
[Set OpenSSL engine for BIND]
[Checking for deprecated KDC configuration files]
[Checking for deprecated backups of Samba configuration files]
dnssec-validation yes
[Add missing CA DNS records]
Upgrading IPA services
Disabled p11-kit-proxy
Restarting ipa-dnskeysyncd
Updating DNS system records
Invalid IP address fe80::{...} for ipa.example.test.: cannot use link-local IP address fe80::{...}
named user config '/data/etc/named/ipa-ext.conf' already exists
named user config '/data/etc/named/ipa-options-ext.conf' already exists
named user config '/data/etc/named/ipa-logging-ext.conf' already exists
[Upgrading CA schema]
CA schema update complete
[Update certmonger certificate renewal configuration]
Certmonger certificate renewal configuration already up-to-date
[Enable PKIX certificate path discovery and validation]
[Authorizing RA Agent to modify profiles]
[Authorizing RA Agent to manage lightweight CAs]
[Ensuring Lightweight CAs container exists in Dogtag database]
[Adding default OCSP URI configuration]
[Disabling cert publishing]
pki-tomcat configuration changed, restart pki-tomcat
[Ensuring CA is using LDAPProfileSubsystem]
[Migrating certificate profiles to LDAP]
[Ensuring presence of included profiles]
[Add default CA ACL]
[Updating ACME configuration]
[Migrating to authselect profile]
[Create systemd-user hbac service and rule]
hbac service systemd-user already exists
[Add root@EXAMPLE.TEST alias to admin account]
Alias already exists
[Setup SPAKE]
[Setup PKINIT]
[Enable server krb5.conf snippet]
[Setup kpasswd_server]
[Adding ipa-ca alias to HTTP certificate]
Certificate is OK; nothing to do
The IPA services were upgraded
The ipa-server-upgrade command was successful
FreeIPA server upgraded.
Wed Jan 11 11:15:14 UTC 2023 /usr/sbin/ipa-server-configure-first update-self-ip-address
ipa.example.test has address 172.{...}
FreeIPA server started.

To my untrained eye, nothing seems out of place. Im a little bit stuck...

adelton commented 1 year ago

Before that

FreeIPA server is already configured but with different version

part there was likely a part that actually run ipa-server-install and configured the FreeIPA server, and it clearly passed. And there you would also see the sudo docker run commands and their parameters.

That should give you a baseline for incrementally tweaking the parameters from the working setup to the parameters in your example, to figure out which one is making the difference and breaking the CA configuration.

microbioticajon commented 1 year ago

Thanks @adelton, I will give that a try and report back.

microbioticajon commented 1 year ago

After a bit of messing about I was able to get the installation to complete. The critical component of the configuration was -v /mnt/ipa_data:/data:Z where /mnt/ipa_data was an AWS EFS mount. The container absolutely had write permissions to this location as evidenced by the presence of log files and other data/ files and directories written by the container - odd...

Starting the container with a local data folder Im still having issues and cannot connect to the web interface. Im not sure these are related but will post them here:

data/var/log/httpd/error_log

[Sun Jan 15 22:30:21.930014 2023] [suexec:notice] [pid 3752:tid 3752] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun Jan 15 22:30:22.007322 2023] [lbmethod_heartbeat:notice] [pid 3752:tid 3752] AH02282: No slotmem from mod_heartmonitor
[Sun Jan 15 22:30:22.016530 2023] [mpm_event:notice] [pid 3752:tid 3752] AH00489: Apache/2.4.53 (AlmaLinux) OpenSSL/3.0.1 mod_auth_gssapi/1.6.3 mod_wsgi/4.7.1 Python/3.9 configured -- resuming normal operations
[Sun Jan 15 22:30:22.016558 2023] [core:notice] [pid 3752:tid 3752] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Jan 15 22:30:22.025873 2023] [wsgi:alert] [pid 3756:tid 3756] (2)No such file or directory: mod_wsgi (pid=3756): Unable to change working directory to home directory '/var/lib/kdcproxy' for uid=288.
[Sun Jan 15 22:30:22.025899 2023] [wsgi:alert] [pid 3756:tid 3756] mod_wsgi (pid=3756): Failure to configure the daemon process correctly and process left in unspecified state. Restarting daemon process after delay.
[Sun Jan 15 22:30:22.044199 2023] [wsgi:alert] [pid 3755:tid 3755] (2)No such file or directory: mod_wsgi (pid=3755): Unable to change working directory to home directory '/var/lib/kdcproxy' for uid=288.
.............. repeating.....

This is generating a lot of log entries...

And probably unrelated - /data/var/log/pki/pki-tomcat/ca/debug.2023-01-15.log ends in a continuous loop of:

2023-01-15 22:31:20 [AuthorityMonitor] SEVERE: LdapBoundConnFactory: Unable to create master connection: Unable to connect to LDAP server: Unable to create socket: java.net.ConnectException: Connection refused
Unable to connect to LDAP server: Unable to create socket: java.net.ConnectException: Connection refused
...
2023-01-15 22:31:20 [AuthorityMonitor] WARNING: AuthorityMonitor: Failed to get LDAPConnection: Unable to connect to LDAP server: Unable to create socket: java.net.ConnectException: Connection refused
Unable to connect to LDAP server: Unable to create socket: java.net.ConnectException: Connection refused
...

Im much further than I was so thanks for your help @adelton

microbioticajon commented 1 year ago

Update - I can connect to the web server! But the logs filling up with wsgi:alerts is still a thing.

I will close this issue as it has largely been resolved (issue with data/ volume mount). If there is a comment to be made regarding the logs Im seeing then please feel free to comment but otherwise, thanks for your help!