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 1832364

Summary: User-signed CMC requests approval failed fail Invalid Credential Error
Product: Red Hat Enterprise Linux 7 Reporter: shalini <skhandel>
Component: pki-coreAssignee: RHCS Maintainers <rhcs-maint>
Status: CLOSED DUPLICATE QA Contact: PKI QE <bugzilla-pkiqe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.9CC: cfu, jmagne
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: 2020-05-19 00:43:09 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:

Description shalini 2020-05-06 15:16:36 UTC
Description of problem:
User-signed CMC requests approval failed fail Invalid Credential Error


Version-Release number of selected component (if applicable):
rpm -qa | grep pki
pki-kra-10.5.18-3.el7.noarch
pki-server-10.5.18-3.el7.noarch
pki-ca-10.5.18-3.el7.noarch
pki-console-10.5.18-3.el7pki.noarch
redhat-pki-10.5.18-2.el7pki.noarch
jss-4.4.9-2.el7.x86_64
tomcatjss-7.2.5-1.el7.noarch



How reproducible:
Always

Test Setup:
> Discrete tomcat RSA-installation with ca, kra and ocsp installed on Non-HSM machine
> caFullCMCUserCert profile is enabled.
> local nssdb path : /opt/pki/certdb/

Steps to Reproduce:
1. Generate a  CRMF request using following command:

>>> CRMFPopClient -h internal -d /opt/pki/certdb -p SECret.123 -n 'CN=Testing,UID=shal2,O=Test Cert' -o /tmp/shal.csr -q POP_SUCCESS -w AES/CBC/PKCS5Padding

Keypair private key id: -72922c074070ec5e15ce002b29477d1bfc9eba5f
Storing CRMF request into /tmp/shal.csr
Storing CRMF request key id into /tmp/shal.csr.keyId


2. Copy generated key in cmc.cfg as follows:

>>>>cat shalcmc.cfg
format=crmf
numRequests=1
tokenname=internal
input=/tmp/shal.csr
output=/tmp/shalcmc_request.csr
password=SECret.123
nickname=PKI CA Administrator for Example.Org
dbdir=/opt/pki/certdb
request.privKeyId=-72922c074070ec5e15ce002b29477d1bfc9eba5f

3. Generate a CMCRequest using following command:
>>>> CMCRequest shalcmc.cfg 

cert/key prefix = 
path = /opt/pki/certdb
CryptoManger initialized
token internal logged in...
got signerCert: PKI CA Administrator for Example.Org
createPKIData: begins
k=0
createPKIData:  format: crmf
useSharedSecret is false...
signData: begins: 
getPrivateKey: got signing cert
signData:  got signer privKey
createSignedData: begins
getSigningAlgFromPrivate: begins.
getSigningAlgFromPrivate: found signingKeyType=RSA
getSigningAlgFromPrivate: using SignatureAlgorithm: RSASignatureWithSHA256Digest
createSignedData: digest created for pkidata
createSignedData: digest algorithm =RSASignatureWithSHA256Digest
createSignedData: building cert chain
signData: signed request generated.
getCMCBlob: begins
getCMCBlob: generating signed data

The CMC enrollment request in base-64 encoded format:

MIIMpAYJKoZIhvcNAQcCoIIMlTCCDJECAQMxDzANBglghkgBZQMEAgEFADCCArMG
.
. Output omited
.
26vmU9wjwp5i8IPd2viBqAv7stowjrh+

The CMC enrollment request in binary format is stored in /tmp/shalcmc_request.csr


4. Create a http.cfg file as follows:
>>>> cat shalhttp.cfg 
clientmode=true
secure=true
nickname=PKI CA Administrator for Example.Org
tokenname=internal
host=pki1.example.com
output=/tmp/shalcmc_response.crt
input=/tmp/shalcmc_request.csr
password=SECret.123
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caFullCMCUserCert
port=20443
dbdir=/opt/pki/certdb


5. Send CMC request for approval using HttpClient using following command:
>>> HttpClient /tmp/shalhttp.cfg

Total number of bytes read = 3240
after SSLSocket created, thread token is Internal Key Storage Token
client cert is not null
handshake happened
writing to socket
Total number of bytes read = 1636
MIIGYAYJKoZIhvcNAQcCoIIGUTCCBk0CAQMxDzANBglghkgBZQMEAgMFADBJBggr
.
. Output omitted
.
+cJWeqf2madqdXFPS9vSOFfeZKgVcYjxcsAJTpMGIUc6oWfhlm6DHi69xyxO/izQ
thyu1g==

The response in binary format is stored in /tmp/shalcmc_response.crt

6. Validate the response using following command:

>>>>> CMCResponse -d /opt/pki/certdb/ -i /tmp/shalcmc_response.crt
Certificates: 
    Certificate: 
        Data: 
            Version:  v3
            Serial Number: 0x1
.
. output omitted
.


Number of controls is 1
Control #0: CMCStatusInfoV2
   OID: {1 3 6 1 5 5 7 7 25}
   BodyList: 0 
   Status String: Invalid Credential.
   OtherInfo type: FAIL
     failInfo=bad request
CMC Full Response.
ERROR: CMC status for [0]: failed


Actual results:
Output of CMCResponse shows: Invalid Credential
Debug logs on execution of step 5 shows below:

[06/May/2020:11:04:32][http-bio-20443-exec-7]: CMCOutputTemplate: getContentInfo:  - done
[06/May/2020:11:04:32][http-bio-20443-exec-7]: SignedAuditLogger: event CMC_RESPONSE_SENT
[06/May/2020:11:04:32][http-bio-20443-exec-7]: ProfileSubmitCMCServlet: authentication error Invalid Credential.
[06/May/2020:11:04:32][http-bio-20443-exec-7]: CMSServlet: curDate=Wed May 06 11:04:32 EDT 2020 id=caProfileSubmitCMCFull time=39
[06/May/2020:11:04:32][http-bio-20443-exec-7]: SignedAuditLogger: event ACCESS_SESSION_TERMINATED


Expected results:
Output of CMCResponse should show approved cert.


Additional info:
User-signed CMC requests approval is validated as per section 5.1 of following documentation, and it failed of pkcs10 request type with same error:
https://www.dogtagpki.org/wiki/PKI_10.4_CMC_Feature_Update_(RFC5272)#User-signed_CMC_requests_Example_.28with_PopLinkWitnessV2.29

Above steps is a regression steps and are run in pipelines for RHEL7.8 and worked fine that time.


Attached are all the files and CA debug logs for same.

Comment 3 Christina Fu 2020-05-15 23:31:34 UTC
My research tracked this
https://github.com/dogtagpki/pki/blob/DOGTAG_10_5_BRANCH/base/server/cms/src/com/netscape/cms/authentication/CMCAuth.java#L586
to
https://github.com/dogtagpki/pki/blob/DOGTAG_10_5_BRANCH/base/util/src/netscape/security/x509/X509CertInfo.java#L340

Which was called by
https://github.com/dogtagpki/pki/blob/DOGTAG_10_5_BRANCH/base/util/src/netscape/security/x509/X509CertInfo.java#L624
and that's introduced by ba48744b071fa5aa0dc04886745710699ca24139
as part of the PSS patch.

I have already spoken to Jack about this.
Alll that's needed to fix this issue is to remove that logger.warn line.  I think the toString() method is meant for when the X509Info has been populated, not when it's first created with "new".