-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8271199: Mutual TLS handshake fails signing client certificate with custom sensitive PKCS11 key #4887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8271199: Mutual TLS handshake fails signing client certificate with custom sensitive PKCS11 key #4887
Changes from 2 commits
9f0e89a
d2b371d
b336e36
df6f212
ede6436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,26 @@ private RSAKey isValid(RSAKey rsaKey) throws InvalidKeyException { | |
("Unrecognized digest algo: " + digestAlgo); | ||
} | ||
} | ||
|
||
// validate key attributes | ||
try { | ||
if (rsaKey.getModulus().signum() == 0 || | ||
(rsaKey instanceof RSAPrivateKey rsaPrKey && | ||
(rsaPrKey.getPrivateExponent().signum() == 0 || | ||
(rsaPrKey instanceof RSAPrivateCrtKey crtKey && | ||
(crtKey.getPrimeP().signum() == 0 || | ||
crtKey.getPrimeQ().signum() == 0 || | ||
crtKey.getPrimeExponentP().signum() == 0 || | ||
crtKey.getPrimeExponentQ().signum() == 0 || | ||
crtKey.getCrtCoefficient().signum() == 0 || | ||
crtKey.getPublicExponent().signum() == 0 )))) || | ||
(rsaKey instanceof RSAPublicKey rsaPubKey && | ||
rsaPubKey.getPublicExponent().signum() == 0)) { | ||
throw new InvalidKeyException("Invalid key attributes"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exception description may be confusing to users. I'm not sure if the checking could be simplified and make this exception message better matching the problems. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the motivation to check the signum? |
||
} catch(Exception ex) { | ||
throw new InvalidKeyException("Invalid key attributes", ex); | ||
} | ||
return rsaKey; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing the public key and private key together in one method may be not straightforward enough to logics like this update. What do you think it we have two isvalid() method, one for private key and one for public key?