Skip to content

Commit a8bb1c5

Browse files
committed
Fix cert serial number padding
1 parent 6ab3578 commit a8bb1c5

File tree

1 file changed

+2
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ private static HashingStorage setItem(HashingStorageLibrary hlib, HashingStorage
192192
@TruffleBoundary
193193
private static String getSerialNumber(X509Certificate x509Certificate) {
194194
String sn = x509Certificate.getSerialNumber().toString(16).toUpperCase();
195-
return sn.length() == 1 ? "0" + sn : sn;
195+
// i2a_ASN1_INTEGER pads the number to have even number of digits
196+
return sn.length() % 2 == 0 ? sn : '0' + sn;
196197
}
197198

198199
@TruffleBoundary

0 commit comments

Comments
 (0)