Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1455200

Summary: IPA server installation with --external-ca fails due pkispawn error
Product: Red Hat Enterprise Linux 7 Reporter: Abhijeet Kasurde <akasurde>
Component: pki-coreAssignee: Fraser Tweedale <ftweedal>
Status: CLOSED WONTFIX QA Contact: Asha Akkiangady <aakkiang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: arubin, ftweedal, mharmsen, pvoborni, rcritten, tscherf
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-26 15:16:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
ipa-server-install.log
none
pki-ca-spawn.log
none
bug_reproduce.sh none

Description Abhijeet Kasurde 2017-05-24 12:57:33 UTC
Description of problem:
while trying to install ipa server with '--external-ca', installer fails due to pkispawn error 

2017-05-24T12:51:24Z DEBUG stdout=Log file: /var/log/pki/pki-ca-spawn.20170524085026.log
Loading deployment configuration from /tmp/tmpf9VG9O.
Installing CA into /var/lib/pki/pki-tomcat.

Installation failed:
com.netscape.certsrv.base.PKIException: Error in setting certificate names and key sizes: java.io.IOException: Unable to create local certificate: extension not found

Please check the CA logs in /var/log/pki/pki-tomcat/ca.

2017-05-24T12:51:24Z DEBUG stderr=
2017-05-24T12:51:24Z CRITICAL Failed to configure CA instance: Command '/usr/sbin/pkispawn -s CA -f /tmp/tmpf9VG9O' returned non-zero exit status 1


Version-Release number of selected component (if applicable):
ipa-server-4.5.0-13.el7.x86_64
pki-server-10.4.1-6.el7.noarch


How reproducible:
100%

Steps to Reproduce:
1. Trigger attached shell script which installs IPA server with external signed certificates

Actual results:
Error as above

Expected results:
IPA installer should succeed with externally signed certificates.

Comment 3 Abhijeet Kasurde 2017-05-24 13:00:48 UTC
Created attachment 1281952 [details]
ipa-server-install.log

Comment 4 Abhijeet Kasurde 2017-05-24 13:01:11 UTC
Created attachment 1281953 [details]
pki-ca-spawn.log

Comment 5 Abhijeet Kasurde 2017-05-24 13:04:58 UTC
Created attachment 1281954 [details]
bug_reproduce.sh

Comment 7 Petr Vobornik 2017-05-24 14:44:22 UTC
The PKI error is not very helpful:

com.netscape.certsrv.base.PKIException: Error in setting certificate names and key sizes: java.io.IOException: Unable to create local certificate: extension not found

Which certificate, key, extension?

Looks as hardened validation. 

Fraser any idea if the issues is in IPA, PKI, usage?

Comment 8 Fraser Tweedale 2017-05-25 01:34:35 UTC
The problem is that the External CA's certificate does not have an AuthorityKeyIdentifier extension.  So it is user error.  But the "fix"
will be better error reporting and, ideally, a sanity check in IPA to
prevent installation from proceeding and to explain to the user
what has to be changed.

Comment 9 Fraser Tweedale 2017-05-25 05:20:00 UTC
Here is a n updated version of the attached script
that adds the required extensions.

(note: I changed the $PASSWORD and $domain variables, too)

---

#!/bin/bash

PASSWORD="4me2Test"
DBDIR="/root/nssdb"
PWDFILE="$DBDIR/pwdfile.txt"
NOISE="/etc/passwd"

domain="IPA.LOCAL"

IP=$(ip addr|grep "global"|cut -d " " -f6|cut -d "/" -f1|head -n 1)

/usr/sbin/ipa-server-install -p ${PASSWORD} -a ${PASSWORD} --ip-address ${IP} --domain ${domain} -r ${domain^^} --setup-dns --no-reverse --auto-forwarders -U --external-ca

ROOT_KEY_ID=0x$(dd if=/dev/urandom bs=20 count=1 | xxd -p)
IPA_CA_KEY_ID=0x$(dd if=/dev/urandom bs=20 count=1 | xxd -p)

rm -rf "$DBDIR"
mkdir "$DBDIR"
echo "$PASSWORD" > "$PWDFILE"
certutil -N -d "$DBDIR" -f "$PWDFILE"
echo -e "0\n1\n5\n6\n9\ny\ny\n\ny\n${ROOT_KEY_ID}\nn\n" \
  | certutil -d "$DBDIR"  -f "$PWDFILE" -S -z "$NOISE" -n ca -x -t C,C,C \
    -s "CN=PRIMARY,O=IPA.LOCAL" -x -1 -2 --extSKID

openssl req -outform der -in /root/ipa.csr -out "$DBDIR/req.csr"
echo -e "0\n1\n5\n6\n9\ny\ny\n\ny\ny\n${ROOT_KEY_ID}\n\n\nn\n${IPA_CA_KEY_ID}\nn\n" \
  | certutil -d "$DBDIR" -f "$PWDFILE" -C -z "$NOISE" -c ca \
    -i "$DBDIR/req.csr" -o "$DBDIR/external.cer" -1 -2 -3 --extSKID

openssl x509 -inform der -in "$DBDIR/external.cer" -out "$DBDIR/external.pem"
certutil -L -n ca -d "$DBDIR" -a > "$DBDIR/ca.crt"
cat "$DBDIR/external.pem" "$DBDIR/ca.crt" > "$DBDIR/chain.crt"
ipa-server-install --external-cert-file "$DBDIR/chain.crt" -p ${PASSWORD}

Comment 10 Petr Vobornik 2017-05-25 12:20:45 UTC
It's good that the error reporting will be improved.

Unfortunately atm. the only options IPA installer has is to either:
- re-implement the check
- fail when pkispawn ends on validation the input, which is too late in installation

So the better error will help only partially - but better than nothing.

Best would be to have `pkispawn --validate` mode which would only validate input so that IPA installer can call it in it's validation step. Jcholast created RFE for that long time ago. But that is obviously not for IPA 4.5 or PKI 10.4.1