yandrey321 commented on code in PR #12114:
URL: https://github.com/apache/ozone/pull/12114#discussion_r4675289088
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMSecurityProtocolServer.java:
##########
@@ -331,31 +332,36 @@ public String getSCMCertificate(ScmNodeDetailsProto
scmNodeDetails,
LOGGER.info("Processing CSR for scm {}, nodeId: {}",
scmNodeDetails.getHostName(), scmNodeDetails.getScmNodeId());
- return getEncodedCertToString(certSignReq, NodeType.SCM);
+ return getEncodedCertToString(certSignReq, NodeType.SCM, null);
}
/**
* Request certificate for the specified role.
* @param certSignReq - Certificate signing request.
* @param nodeType - role OM/SCM/DATANODE
+ * @param nodeId - UUID of the requester, for its commonName if the CSR's is
too long; ignored for SCM, whose SCM ID
+ * is in the CSR subject.
* @return String - SCM signed pem encoded certificate.
* @throws IOException
*/
private synchronized String getEncodedCertToString(String certSignReq,
- NodeType nodeType) throws IOException {
+ NodeType nodeType, String nodeId) throws IOException {
if (nodeType == NodeType.SCM) {
// SCM role certificates are CA certificates and are issued to SCM
admins only, the check addSCM applies.
storageContainerManager.checkAdminAccess(getRpcRemoteUser(), false);
}
checkRequesterIsService(nodeType);
Future<CertPath> future;
PKCS10CertificationRequest csr = getCertificationRequest(certSignReq);
+ // The same commonName as CertificateSignRequest.commonName gives a client
of this version.
+ String commonNameIfTooLong =
CertificateSignRequest.commonNamePrefix(nodeType) + "@"
Review Comment:
Fixed and tested.
- For getSCMCertificate, SCM now uses ScmNodeDetailsProto.scmNodeId, a
required field that SCMCertificateClient sets to the SCM ID, instead of parsing
the CSR's OU. Every RPC now takes its ID from the request, the replacement is
always <prefix>@<id>, and scm-sub@null can't happen.
CertificateSignRequest.getScmId is removed.
- New TestSCMSecurityProtocolServer: one test per RPC, each sent as that
role's Kerberos service user. Each checks the replacement CN passed to the CA:
- getDataNodeCertificate: dn@<datanode UUID>
- getOMCertificate: om@<OM UUID>
- getCertificate for Recon: recon@<Recon UUID>
- getSCMCertificate: scm-sub@<scmNodeId>, sent to the root CA server
I checked the tests catch a swap: passing the OM host name instead of its
UUID fails testOMCertificate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]