Copilot commented on code in PR #12114:
URL: https://github.com/apache/ozone/pull/12114#discussion_r4677237705
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateApprover.java:
##########
@@ -64,6 +64,31 @@ X509Certificate sign(
String scmId,
String clusterId,
String certSerialId)
+ throws IOException, CertificateException {
+ return sign(config, caPrivate, caCertificate, validFrom, validTill,
certificationRequest, scmId, clusterId,
+ certSerialId, null);
+ }
+
+ /**
+ * Like {@link #sign(SecurityConfig, PrivateKey, X509Certificate, Date,
Date, PKCS10CertificationRequest, String,
+ * String, String)}, with the commonName to use instead of the CSR's when
that is longer than RFC 5280
+ * ub-common-name, as in a CSR from a client that predates
+ * {@link
org.apache.hadoop.hdds.security.x509.certificate.utils.CertificateSignRequest#commonName}.
+ *
+ * @param commonNameIfTooLong - commonName for a CSR commonName longer than
64 characters, or null to keep it.
+ */
+ @SuppressWarnings("ParameterNumber")
+ X509Certificate sign(
+ SecurityConfig config,
+ PrivateKey caPrivate,
+ X509Certificate caCertificate,
+ Date validFrom,
+ Date validTill,
+ PKCS10CertificationRequest certificationRequest,
+ String scmId,
+ String clusterId,
+ String certSerialId,
+ String commonNameIfTooLong)
Review Comment:
The same compatibility break exists for `CertificateApprover`: an approver
compiled against the old nine-argument method does not implement this newly
abstract ten-argument method, so calls through the updated interface can fail
with `AbstractMethodError`. The overload carrying `commonNameIfTooLong` should
be a default that delegates to the existing method, while `DefaultApprover` can
override it to support the new behavior.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateServer.java:
##########
@@ -91,10 +91,23 @@ X509Certificate getCertificate(String certSerialId)
* approved.
* @throws SCMSecurityException - on Error.
*/
+ default Future<CertPath> requestCertificate(
+ PKCS10CertificationRequest csr,
+ CertificateApprover.ApprovalType type, NodeType role,
+ String certSerialId) throws SCMSecurityException {
+ return requestCertificate(csr, type, role, certSerialId, null);
+ }
+
+ /**
+ * Like {@link #requestCertificate(PKCS10CertificationRequest,
CertificateApprover.ApprovalType, NodeType, String)},
+ * with the commonName to issue instead of the CSR's when that is longer
than RFC 5280 ub-common-name.
+ *
+ * @param commonNameIfTooLong - commonName for a CSR commonName longer than
64 characters, or null to keep it.
+ */
Future<CertPath> requestCertificate(
PKCS10CertificationRequest csr,
CertificateApprover.ApprovalType type, NodeType role,
- String certSerialId) throws SCMSecurityException;
+ String certSerialId, String commonNameIfTooLong) throws
SCMSecurityException;
Review Comment:
Making the new five-argument overload abstract breaks any existing
`CertificateServer` implementation that only implements the pre-existing
four-argument method: updated callers can dispatch to an unimplemented
interface method and get `AbstractMethodError` (and such implementations no
longer compile). To preserve the advertised overload compatibility, keep the
old method as the implementation contract and make the new overload a default
that delegates to it, with `DefaultCAServer` overriding the new overload for
the replacement-CN behavior.
--
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]