3030
3131final class ClientCertificate implements IClientCertificate {
3232
33- private final static int MIN_KEY_SIZE_IN_BITS = 2048 ;
3433 public static final String DEFAULT_PKCS12_PASSWORD = "" ;
3534
3635 @ Accessors (fluent = true )
@@ -47,30 +46,6 @@ final class ClientCertificate implements IClientCertificate {
4746
4847 this .privateKey = privateKey ;
4948
50- if (privateKey instanceof RSAPrivateKey ) {
51- if (((RSAPrivateKey ) privateKey ).getModulus ().bitLength () < MIN_KEY_SIZE_IN_BITS ) {
52- throw new IllegalArgumentException (
53- "certificate key size must be at least " + MIN_KEY_SIZE_IN_BITS );
54- }
55- } else if ("sun.security.mscapi.RSAPrivateKey" .equals (privateKey .getClass ().getName ()) ||
56- "sun.security.mscapi.CPrivateKey" .equals (privateKey .getClass ().getName ())) {
57- try {
58- Method method = privateKey .getClass ().getMethod ("length" );
59- method .setAccessible (true );
60- if ((int ) method .invoke (privateKey ) < MIN_KEY_SIZE_IN_BITS ) {
61- throw new IllegalArgumentException (
62- "certificate key size must be at least " + MIN_KEY_SIZE_IN_BITS );
63- }
64- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex ) {
65- throw new RuntimeException ("error accessing sun.security.mscapi.RSAPrivateKey length: "
66- + ex .getMessage ());
67- }
68- } else {
69- throw new IllegalArgumentException (
70- "certificate key must be an instance of java.security.interfaces.RSAPrivateKey or" +
71- " sun.security.mscapi.RSAPrivateKey" );
72- }
73-
7449 this .publicKeyCertificateChain = publicKeyCertificateChain ;
7550 }
7651
0 commit comments