[JIRA] (JENKINS-59331) withCredentials certificate(aliasVariable: ) stores description of credential, not keystore alias name

10 views
Skip to first unread message

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 27, 2019, 1:39:05 PM11/27/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo updated an issue
 
Jenkins / Bug JENKINS-59331
withCredentials certificate(aliasVariable: ) stores description of credential, not keystore alias name
Change By: Kalle Niemitalo
Summary: Empty 'Alias Variable' when using withCredentials certificate binding (aliasVariable: ) stores description of credential, not keystore alias name
Issue Type: Task Bug
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 27, 2019, 1:52:02 PM11/27/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo commented on Bug JENKINS-59331
 
Re: withCredentials certificate(aliasVariable: ) stores description of credential, not keystore alias name

Credentials Binding Plugin has done this ever since the certificate binding feature was added commit 7d789a8c590fd87cb9dd61c89c894a5df26a0605 and merged in PR#39. The commit message even mentions the assumption that the credential description matches the keystore alias name, but I don't think I have seen it documented anywhere else. When I edit the description of a certificate credential, the help text "An optional description to help tell similar credentials apart" certainly gives no hint of any such requirement.

CertificateMultiBinding already calls credentials.getKeyStore(), so perhaps it could just enumerate the returned KeyStore and get the alias name from there, without needing changes in the Credentials Plugin. If the aliasVariable parameter is specified but the KeyStore actually contains more than one key, then CertificateMultiBinding could log a warning about that.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 27, 2019, 1:53:03 PM11/27/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-59331
Credentials Binding Plugin has done this ever since the certificate binding feature was added in [commit 7d789a8c590fd87cb9dd61c89c894a5df26a0605|https://github.com/jenkinsci/credentials-binding-plugin/commit/7d789a8c590fd87cb9dd61c89c894a5df26a0605] and merged in [PR#39|https://github.com/jenkinsci/credentials-binding-plugin/pull/39]. The commit message even mentions the assumption that the credential description matches the keystore alias name, but I don't think I have seen it documented anywhere else. When I edit the description of a certificate credential, the help text "An optional description to help tell similar credentials apart" certainly gives no hint of any such requirement.

CertificateMultiBinding already calls {{credentials.getKeyStore()}}, so perhaps it could just enumerate the returned KeyStore and get the alias name from there, without needing changes in the Credentials Plugin. If the {{aliasVariable}} parameter is specified but the KeyStore actually contains more than one key, then CertificateMultiBinding could log a warning about that.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 27, 2019, 2:04:03 PM11/27/19
to jenkinsc...@googlegroups.com


If each certificate credential normally contains only one certificate and private key, then the keystore alias name is not really needed for selecting the correct certificate, and I think users are likely to choose short words like "cert" as keystore alias names. If the {{withCredentials}} step is then changed to store these to the {{aliasVariable}}, there may be a risk that Jenkins starts unnecessarily masking this word in unrelated output. Perhaps the keystore alias name should be exempt from this masking.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 28, 2019, 6:21:04 AM11/28/19
to jenkinsc...@googlegroups.com

In the Certificate Plugin, CertificateCredentialsImpl.KeyStoreSourceDescriptor#validateCertificateKeystore apparently supports multiple certificate entries and multiple key entries in the same KeyStore. StandardCertificateCredentials.NameProvider#getSubjectDN only uses one key entry, though.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 28, 2019, 6:25:03 AM11/28/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-59331
Credentials Binding Plugin has done this ever since the certificate binding feature was added in [commit 7d789a8c590fd87cb9dd61c89c894a5df26a0605|https://github.com/jenkinsci/credentials-binding-plugin/commit/7d789a8c590fd87cb9dd61c89c894a5df26a0605] and merged in [PR#39|https://github.com/jenkinsci/credentials-binding-plugin/pull/39]. The commit message even mentions the assumption that the credential description matches the keystore alias name, but I don't think I have seen it documented anywhere else. When I edit the description of a certificate credential, the help text "An optional description to help tell similar credentials apart" certainly gives no hint of any such requirement.

CertificateMultiBinding already calls {{credentials.getKeyStore()}}, so perhaps it could just enumerate the returned KeyStore and get the alias name from there, without needing changes in the Credentials Plugin. If the {{aliasVariable}} parameter is specified but the KeyStore actually contains more than one key, then CertificateMultiBinding could log a warning about that.

If each certificate credential normally contains only one certificate and private key, then the keystore alias name is not really needed for selecting the correct certificate, and I think users are likely to choose short words like "cert" as keystore alias names. If the {{withCredentials}} step is then changed to store these to the {{aliasVariable}}, there may be a risk that Jenkins starts unnecessarily masking this word in unrelated output. Perhaps the keystore alias name should be exempt from this masking , like JENKINS-44860 requests for usernames .

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Nov 28, 2019, 7:18:03 AM11/28/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-59331
Credentials Binding Plugin has done this ever since the certificate binding feature was added in [commit 7d789a8c590fd87cb9dd61c89c894a5df26a0605|https://github.com/jenkinsci/credentials-binding-plugin/commit/7d789a8c590fd87cb9dd61c89c894a5df26a0605] and merged in [PR#39|https://github.com/jenkinsci/credentials-binding-plugin/pull/39]. The commit message even mentions the assumption that the credential description matches the keystore alias name, but I don't think I have seen it documented anywhere else. When I edit the description of a certificate credential, the help text "An optional description to help tell similar credentials apart" certainly gives no hint of any such requirement.

CertificateMultiBinding already calls {{credentials.getKeyStore()}}, so perhaps it could just enumerate the returned KeyStore and get the alias name from there, without needing changes in the Credentials Plugin. If the {{aliasVariable}} parameter is specified but the KeyStore actually contains more than one key, then CertificateMultiBinding could log a warning about that , perhaps unless the description of the credential matches one of these aliases .


If each certificate credential normally contains only one certificate and private key, then the keystore alias name is not really needed for selecting the correct certificate, and I think users are likely to choose short words like "cert" as keystore alias names. If the {{withCredentials}} step is then changed to store these to the {{aliasVariable}}, there may be a risk that Jenkins starts unnecessarily masking this word in unrelated output. Perhaps the keystore alias name should be exempt from this masking, like JENKINS-44860 requests for usernames.
Reply all
Reply to author
Forward
0 new messages