Skip to content

Commit

Permalink
chore: fix style and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Taowyoo committed Sep 6, 2023
1 parent cda6c69 commit 2efce34
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion key-attestation/java-example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ buildNumber.properties
# JDT-specific (Eclipse Java Development Tools)
.classpath

/.vscode
/.vscode
2 changes: 1 addition & 1 deletion key-attestation/java-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@
</plugin>
</plugins>
</reporting>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,15 @@ private static X500Name buildX500Name(String c, String st, String l, String o, S
if (!c.isEmpty()) {
builder.addRDN(BCStyle.C, c);
}
;
if (!st.isEmpty()) {
builder.addRDN(BCStyle.ST, st);
}
;
if (!l.isEmpty()) {
builder.addRDN(BCStyle.L, l);
}
;
if (!o.isEmpty()) {
builder.addRDN(BCStyle.O, o);
}
;
builder.addRDN(BCStyle.CN, cn);

return builder.build();
Expand Down Expand Up @@ -174,10 +170,10 @@ private static boolean checkRDNsMatch(X500Name actual, X500Name expected, ASN1Ob
public static void isValidCrlUrl(String urlString) throws Exception {
URL url = new URL(urlString);
if (!url.getProtocol().equals("https")) {
throw new KeyAttestationStatementVerifyException("invalid CRL URL: invalid domain");
throw new KeyAttestationStatementVerifyException("invalid CRL URL: should be https");
}
if (!url.getHost().equalsIgnoreCase(FORTANIX_PKI_DOMAIN)) {
throw new KeyAttestationStatementVerifyException("invalid CRL URL: should be https");
throw new KeyAttestationStatementVerifyException("invalid CRL URL: invalid domain");
}
if (!url.getPath().endsWith(".crl")) {
throw new KeyAttestationStatementVerifyException("invalid CRL URL: should be end with '.crl'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void verify(KeyAttestationResponse keyAttestationResponse,
/**
* Verify given `attestationStatement`, `authorityChain` by using `trustRootCa`
*
* @param authorityChain Certificate chain of all certificates expect
* @param authorityChain Certificate chain of all certificates except
* `Fortanix Key Attestation Statement` certificate
* @param attestationStatement `Fortanix Key Attestation Statement` certificate
* @param trustRootCa Trusted root CA, you need to get the certificate
Expand All @@ -87,10 +87,10 @@ public static void verify(List<X509Certificate> authorityChain, X509Certificate
// it's parent
try {
verify_cert_chain_signature(authorityChain, trustRootCa, verifyCrl);
System.out.println("The signature in 'Fortanix DSM Key Attestation' certificate is valid.");
System.out.println("The signature in 'Fortanix DSM Key Attestation' certificate is invalid.");
} catch (Exception e) {
throw new KeyAttestationStatementVerifyException(
"The signature in 'Fortanix DSM Key Attestation' certificate is valid, " + e.toString());
"The signature in 'Fortanix DSM Key Attestation' certificate is invalid, " + e.toString());
}
LOGGER.info(String.format("Checking if '%s' certificate is correctly signed by '%s' certificate",
Common.DSM_CLUSTER_KEY_ATTESTATION_AUTHORITY_CN, Common.KEY_ATTESTATION_STATEMENT_CN));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void check_public_key(X509Certificate cert) throws Exception {
PublicKey rootPk = cert.getPublicKey();
if (rootPk instanceof RSAPublicKey) {
RSAPublicKey rootRsaPk = (RSAPublicKey) rootPk;
assert (rootRsaPk.getModulus().bitLength() >= 3072);
assert (rootRsaPk.getModulus().bitLength() >= 4096);
} else {
throw new KeyAttestationStatementVerifyException(
Common.FORTANIX_ATTESTATION_AND_PROVISIONING_ROOT_CA_CN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void check_public_key(X509Certificate cert) throws Exception {
PublicKey caPk = cert.getPublicKey();
if (caPk instanceof RSAPublicKey) {
RSAPublicKey caRsaPk = (RSAPublicKey) caPk;
assert (caRsaPk.getModulus().bitLength() >= 3072);
assert (caRsaPk.getModulus().bitLength() >= 4096);
} else {
throw new KeyAttestationStatementVerifyException(
Common.FORTANIX_KEY_ATTESTATION_CA_CN + " certificate invalid public key type");
Expand Down

0 comments on commit 2efce34

Please sign in to comment.