Skip to content

Commit ba67ad1

Browse files
committed
Warn for insecure PEM file encryption
1 parent 7f20dc0 commit ba67ad1

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

java/org/apache/tomcat/util/net/jsse/LocalStrings.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jsseUtil.excludeProtocol=The SSL protocol [{0}] which is supported in this JRE w
2020
jsseUtil.noDefaultProtocols=Unable to determine a default for sslEnabledProtocols. Set an explicit value to ensure the connector can start.
2121
jsseUtil.opensslconf.present=A connector is configured to use a JSSE TLS implementation with OpenSSL specific OpenSSLConf configuration elements. The OpenSSLConf configuration elements will be ignored.
2222

23+
pemFile.encryption.broken=The PEM file [{0}] is using [{1}] which is considered broken because a brute force attack is trivial with current hardware
24+
pemFile.encryption.insecure=The PEM file [{0}] is using [{1}] which is considered insecure as it is vulnerable to a brute-force attack
2325
pemFile.noMultiPrimes=The PKCS#1 certificate is in multi-prime format and Java does not provide an API for constructing an RSA private key object from that format
2426
pemFile.noPassword=A password is required to decrypt the private key
2527
pemFile.notPbkdf2=The OID [{0}] is not the correct OID for PKBDF2 which is the only permitted KDF for PBES2

java/org/apache/tomcat/util/net/jsse/PEMFile.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
import javax.crypto.spec.PBEKeySpec;
5252
import javax.crypto.spec.SecretKeySpec;
5353

54+
import org.apache.juli.logging.Log;
55+
import org.apache.juli.logging.LogFactory;
5456
import org.apache.tomcat.util.buf.Asn1Parser;
5557
import org.apache.tomcat.util.buf.Asn1Writer;
5658
import org.apache.tomcat.util.buf.HexUtils;
@@ -64,6 +66,7 @@
6466
*/
6567
public class PEMFile {
6668

69+
private static final Log log = LogFactory.getLog(PEMFile.class);
6770
private static final StringManager sm = StringManager.getManager(PEMFile.class);
6871

6972
private static final byte[] OID_EC_PUBLIC_KEY =
@@ -370,18 +373,21 @@ public PrivateKey toPrivateKey(String password, String keyAlgorithm, Format form
370373
secretKeyAlgorithm = "DES";
371374
cipherTransformation = "DES/CBC/PKCS5Padding";
372375
keyLength = 8;
376+
log.error(sm.getString("pemFile.encryption.broken", filename, algorithm));
373377
break;
374378
}
375379
case "DES-EDE3-CBC": {
376380
secretKeyAlgorithm = "DESede";
377381
cipherTransformation = "DESede/CBC/PKCS5Padding";
378382
keyLength = 24;
383+
log.warn(sm.getString("pemFile.encryption.insecure", filename, algorithm));
379384
break;
380385
}
381386
case "AES-256-CBC": {
382387
secretKeyAlgorithm = "AES";
383388
cipherTransformation = "AES/CBC/PKCS5Padding";
384389
keyLength = 32;
390+
log.warn(sm.getString("pemFile.encryption.insecure", filename, algorithm));
385391
break;
386392
}
387393
default:
@@ -501,6 +507,7 @@ public PrivateKey toPrivateKey(String password, String keyAlgorithm, Format form
501507
throw new NoSuchAlgorithmException(
502508
sm.getString("pemFile.unknownEncryptionAlgorithm", toDottedOidString(oidCipher)));
503509
}
510+
log.warn(sm.getString("pemFile.encryption.insecure", filename, algorithm));
504511

505512
byte[] iv = p.parseOctetString();
506513

webapps/docs/changelog.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@
258258
Remove support for HTTP 0.9. (markt)
259259
</update>
260260
<!-- Entries for backport and removal before 12.0.0-M1 below this line -->
261+
<add>
262+
Log a suitable warning if an encrypted PEM file is detected using an
263+
insecure form for encryption. (markt)
264+
</add>
261265
</changelog>
262266
</subsection>
263267
<subsection name="Jasper">

0 commit comments

Comments
 (0)