Skip to content

Commit

Permalink
[registrar] add log msg for newly signed LDevID cert.
Browse files Browse the repository at this point in the history
  • Loading branch information
EskoDijk committed Sep 1, 2024
1 parent 96d79b5 commit 0be65c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/google/openthread/pledge/Pledge.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,12 @@ public void enroll() throws Exception {
cert.verify(domainPublicKey);

subjectName = cert.getSubjectX500Principal().getName();
logger.info("enrolled with operational certificate, subject: " + subjectName);
logger.info("enrolled with operational certificate, subject: {}", subjectName);

operationalCertificate = cert;

logger.info(
"operational certificate (PEM): \n" + SecurityUtils.toPEMFormat(operationalCertificate));
logger.info(
"operational private key (PEM): \n" + SecurityUtils.toPEMFormat(operationalKeyPair));
logger.info("operational certificate (PEM): \n{}", SecurityUtils.toPEMFormat(operationalCertificate));
logger.info("operational private key (PEM): \n{}", SecurityUtils.toPEMFormat(operationalKeyPair));
}

/**
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/google/openthread/registrar/Registrar.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ public void handlePOST(CoapExchange exchange) {

// TODO: check latest draft if JSON mandatory here too.
if (contentFormat != ExtendedMediaTypeRegistry.APPLICATION_CBOR) {
logger.warn(
"unexpected content format for enroll status report: content-format="
+ contentFormat);
logger.warn("unexpected content format for enroll status report: content-format={}", contentFormat);
exchange.respond(
ResponseCode.UNSUPPORTED_CONTENT_FORMAT,
"Only Content Format " + ExtendedMediaTypeRegistry.APPLICATION_CBOR + " supported.");
Expand All @@ -293,10 +291,8 @@ public void handlePOST(CoapExchange exchange) {

enrollStatus = StatusTelemetry.deserialize(exchange.getRequestPayload());
if (enrollStatus.cbor == null) {
logger.warn(
"status telemetry report message decoding error: " + enrollStatus.parseResultStatus);
exchange.respond(
ResponseCode.BAD_REQUEST, "payload error: " + enrollStatus.parseResultStatus);
logger.warn("status telemetry report message decoding error: {}", enrollStatus.parseResultStatus);
exchange.respond(ResponseCode.BAD_REQUEST, "payload error: " + enrollStatus.parseResultStatus);
return;
}

Expand Down Expand Up @@ -724,12 +720,14 @@ public void handlePOST(CoapExchange exchange) {
PKCS10CertificationRequest csr = new PKCS10CertificationRequest(payload);
X509Certificate cert = domainCA.signCertificate(csr);

logger.info("Signed new LDevID cert: subj=[{}]\n{}", cert.getSubjectX500Principal().toString(), SecurityUtils.toPEMFormat(cert));

exchange.respond(
ResponseCode.CHANGED,
cert.getEncoded(),
ExtendedMediaTypeRegistry.APPLICATION_PKIX_CERT);
} catch (Exception e) {
logger.warn("sign certificate failed: " + e.getMessage(), e);
logger.warn("sign certificate failed: {}", e.getMessage(), e);
// TODO(wgtdkp):
exchange.respond(ResponseCode.INTERNAL_SERVER_ERROR);
return;
Expand Down

0 comments on commit 0be65c5

Please sign in to comment.