Skip to content

Commit 8dbb048

Browse files
committed
[GR-74994] Restore JDK 21 compatibility in CertUtils
1 parent e0d0615 commit 8dbb048

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static PrivateKey getPrivateKey(PythonContext context, Node inliningTarget, PCon
733733
PrivateKey privateKey = null;
734734
String algorithm = cert.getPublicKey().getAlgorithm();
735735
try {
736-
String pemText = reader.readAllAsString();
736+
String pemText = readAll(reader);
737737
int fromIndex = 0;
738738
PemBlockWithContent rawBlock;
739739
while ((rawBlock = findNextPemBlock(pemText, fromIndex)) != null) {
@@ -773,6 +773,16 @@ static PrivateKey getPrivateKey(PythonContext context, Node inliningTarget, PCon
773773
return privateKey;
774774
}
775775

776+
private static String readAll(BufferedReader reader) throws IOException {
777+
StringBuilder sb = new StringBuilder();
778+
char[] buf = new char[8192];
779+
int n;
780+
while ((n = reader.read(buf)) != -1) {
781+
sb.append(buf, 0, n);
782+
}
783+
return sb.toString();
784+
}
785+
776786
private static PemBlockWithContent findNextPemBlock(String data, int fromIndex) throws IOException {
777787
int begin = data.indexOf("-----BEGIN ", fromIndex);
778788
if (begin < 0) {

0 commit comments

Comments
 (0)