30
30
31
31
final class ClientCertificate implements IClientCertificate {
32
32
33
- private final static int MIN_KEY_SIZE_IN_BITS = 2048 ;
34
33
public static final String DEFAULT_PKCS12_PASSWORD = "" ;
35
34
36
35
@ Accessors (fluent = true )
@@ -47,30 +46,6 @@ final class ClientCertificate implements IClientCertificate {
47
46
48
47
this .privateKey = privateKey ;
49
48
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
-
74
49
this .publicKeyCertificateChain = publicKeyCertificateChain ;
75
50
}
76
51
0 commit comments