|
34 | 34 | import static com.formkiq.stacks.dynamodb.ConfigService.MAX_WEBHOOKS; |
35 | 35 | import static com.formkiq.stacks.dynamodb.ConfigService.NOTIFICATION_EMAIL; |
36 | 36 |
|
37 | | -import java.security.KeyFactory; |
38 | | -import java.security.NoSuchAlgorithmException; |
39 | | -import java.security.PrivateKey; |
40 | | -import java.security.spec.InvalidKeySpecException; |
41 | | -import java.security.spec.PKCS8EncodedKeySpec; |
42 | 37 | import java.util.ArrayList; |
43 | | -import java.util.Base64; |
44 | 38 | import java.util.Collection; |
45 | 39 | import java.util.HashMap; |
46 | 40 | import java.util.Map; |
@@ -299,23 +293,7 @@ private void validateDocusign(final Map<String, Object> map, |
299 | 293 | } |
300 | 294 |
|
301 | 295 | private boolean isValidRsaPrivateKey(final String privateKeyPem) { |
302 | | - try { |
303 | | - // Remove the PEM header and footer |
304 | | - String privateKeyPemStripped = |
305 | | - privateKeyPem.replace("\\u003d", "=").replace("-----BEGIN RSA PRIVATE KEY-----", "") |
306 | | - .replace("-----END RSA PRIVATE KEY-----", "").replace("\\n", "") |
307 | | - .replaceAll("\\s+", "").trim(); |
308 | | - |
309 | | - byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyPemStripped); |
310 | | - |
311 | | - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); |
312 | | - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); |
313 | | - PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
314 | | - |
315 | | - return privateKey != null; |
316 | | - |
317 | | - } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { |
318 | | - return false; |
319 | | - } |
| 296 | + return privateKeyPem.contains("-----BEGIN RSA PRIVATE KEY-----") |
| 297 | + && privateKeyPem.contains("-----END RSA PRIVATE KEY-----"); |
320 | 298 | } |
321 | 299 | } |
0 commit comments