Bug 1973023

Summary: CA_less ipa-server-install fails if CA cert subject contains non ascii chars
Product: Red Hat Enterprise Linux 8 Reporter: Florence Blanc-Renaud <frenaud>
Component: ipaAssignee: Florence Blanc-Renaud <frenaud>
Status: CLOSED ERRATA QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.5CC: gkaihoro, ksiddiqu, pcech, rcritten, ssidhaye, tscherf, twoerner
Target Milestone: betaKeywords: Triaged
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: 2021-11-09 18:29:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Florence Blanc-Renaud 2021-06-17 06:21:43 UTC
Cloned from upstream: https://pagure.io/freeipa/issue/8880

### Issue
In a CA less setup, if the CA certificate subject contains non-ASCII characters, ipa-server-install fails with a UnicodeDecodeError.

#### Steps to Reproduce
1. Create a CA with subject CN=CA,O=España
2. With this CA, create http and dirsrv certificates CN=server.ipa.test,O=España
3. install the server with ipa-server-install --http-cert-file .. --dirsrv-cert-file .. --ca-cert-file

#### Actual behavior
ipa-server-install fails when configuring SSL for HTTPd:
```
Configuring the web interface (httpd)
  [1/20]: stopping httpd
  [2/20]: backing up ssl.conf
  [3/20]: disabling nss.conf
  [4/20]: configuring mod_ssl certificate paths
  [5/20]: setting mod_ssl protocol list
  [6/20]: configuring mod_ssl log directory
  [7/20]: disabling mod_ssl OCSP
  [8/20]: adding URL rewriting rules
  [9/20]: configuring httpd
  [10/20]: setting up httpd keytab
  [11/20]: configuring Gssproxy
  [12/20]: setting up ssl
  [error] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 67: invalid continuation byte
'utf-8' codec can't decode byte 0xd1 in position 67: invalid continuation byte
The ipa-server-install command failed. See /var/log/ipaserver-install.log for more information
```

#### Expected behavior
The installation should succeed

#### Version/Release/Distribution
freeipa-server-4.9.3-4.fc34.x86_64
freeipa-client-4.9.3-4.fc34.x86_64
389-ds-base-2.0.5-1.fc34.x86_64
pki-ca-10.10.5-6.fc34.noarch
krb5-server-1.19.1-3.fc34.x86_64

#### Additional info:
Traceback:
```
2021-06-09T16:43:35Z DEBUG Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/ipaserver/install/service.py", line 635, in start_creation
    run_step(full_msg, method)
  File "/usr/lib/python3.9/site-packages/ipaserver/install/service.py", line 621, in run_step
    method()
  File "/usr/lib/python3.9/site-packages/ipaserver/install/httpinstance.py", line 331, in __setup_ssl
    p12_certs, p12_priv_keys = certs.pkcs12_to_certkeys(
  File "/usr/lib/python3.9/site-packages/ipaserver/install/certs.py", line 106, in pkcs12_to_certkeys
    pems = ipautil.run(args, capture_output=True).raw_output
  File "/usr/lib/python3.9/site-packages/ipapython/ipautil.py", line 585, in run
    output = stdout.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 67: invalid continuation byte
```

Comment 1 Florence Blanc-Renaud 2021-06-17 06:23:49 UTC
Upstream ticket:
https://pagure.io/freeipa/issue/8880

Comment 2 Florence Blanc-Renaud 2021-06-17 06:24:51 UTC
Fixed upstream:
master:

    fb74866 CA-less install: non-ASCII chars in CA cert subject
    0faddc9 ipatests: use non-ascii chars in CA-less install


ipa-4-9:

    7b278b6 CA-less install: non-ASCII chars in CA cert subject
    4b040e1 ipatests: use non-ascii chars in CA-less install

Comment 9 Ganna Kaihorodova 2021-08-04 12:24:12 UTC
Bugzilla tested and verified with existing test automation and latest rhel8.5 compose

ipa-server-4.9.6-4.module+el8.5.0+11912+1b4496cf.x86_64.rpm 

transport.py               558 DEBUG    Synchronizing time
transport.py               558 DEBUG    No SRV records of NTP servers found and no NTP server or pool address was provided.
transport.py               558 DEBUG    Attempting to sync time with chronyc.
transport.py               558 DEBUG    Process chronyc waitsync failed to sync time!
transport.py               558 DEBUG    Unable to sync time with chrony server, assuming the time is in sync. Please check that 123 UDP port is opened, and any time server is on network.
transport.py               558 DEBUG    Successfully retrieved CA cert
transport.py               558 DEBUG        Subject:     CN=CA,O=Example Organization España
transport.py               558 DEBUG        Issuer:      CN=CA,O=Example Organization España
transport.py               558 DEBUG        Valid From:  2021-08-02 16:42:54
transport.py               558 DEBUG        Valid Until: 2031-07-31 16:42:54

Full verification log in attached file

Comment 11 errata-xmlrpc 2021-11-09 18:29:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (ipa bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4230