Skip to content

Commit 2e334f4

Browse files
committed
Don't fake current OpenSSL version, fake 0.0.0
1 parent 7cd4bb4 commit 2e334f4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_ssl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_get_default_verify_paths
1010
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_malformed_cert
1111
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_malformed_key
12+
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_openssl_version
1213
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_parse_all_sans
1314
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_parse_cert
1415
*graalpython.lib-python.3.test.test_ssl.BasicSocketTests.test_parse_cert_CVE_2013_4238

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,10 @@ public void postInitialize(PythonCore core) {
203203
loadDefaults();
204204
PythonModule module = core.lookupBuiltinModule("_ssl");
205205
PythonObjectFactory factory = PythonObjectFactory.getUncached();
206-
// TODO decide which values to pick
207-
module.setAttribute("OPENSSL_VERSION_NUMBER", 269488287);
208-
PTuple versionInfo = factory.createTuple(new int[]{1, 1, 1, 9, 15});
206+
module.setAttribute("OPENSSL_VERSION_NUMBER", 0);
207+
PTuple versionInfo = factory.createTuple(new int[]{0, 0, 0, 0, 0});
209208
module.setAttribute("OPENSSL_VERSION_INFO", versionInfo);
210-
module.setAttribute("OPENSSL_VERSION", "Java");
209+
module.setAttribute("OPENSSL_VERSION", "GraalVM JSSE");
211210
module.setAttribute("_DEFAULT_CIPHERS", DEFAULT_CIPHER_STRING);
212211
module.setAttribute("_OPENSSL_API_VERSION", versionInfo);
213212

graalpython/lib-python/3/test/test_ssl.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
IS_OPENSSL_1_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 1)
4141
PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS')
4242

43+
IS_GRAALVM_SSL = sys.implementation.name == 'graalpython'
44+
4345
PROTOCOL_TO_TLS_VERSION = {}
4446
for proto, ver in (
4547
("PROTOCOL_SSLv23", "SSLv3"),
@@ -236,7 +238,7 @@ def handle_error(prefix):
236238

237239
def can_clear_options():
238240
# 0.9.8m or higher
239-
return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15)
241+
return IS_GRAALVM_SSL or ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15)
240242

241243
def no_sslv2_implies_sslv3_hello():
242244
# 0.9.7h or higher
@@ -537,6 +539,8 @@ def test_DER_to_PEM(self):
537539
if not p2.endswith('\n' + ssl.PEM_FOOTER + '\n'):
538540
self.fail("DER-to-PEM didn't include correct footer:\n%r\n" % p2)
539541

542+
# We're not OpenSSL
543+
@impl_detail("OpenSSL version", graalvm=False)
540544
def test_openssl_version(self):
541545
n = ssl.OPENSSL_VERSION_NUMBER
542546
t = ssl.OPENSSL_VERSION_INFO
@@ -1128,7 +1132,7 @@ def test_python_ciphers(self):
11281132
self.assertNotIn("RC4", name)
11291133
self.assertNotIn("3DES", name)
11301134

1131-
@unittest.skipIf(ssl.OPENSSL_VERSION_INFO < (1, 0, 2, 0, 0), 'OpenSSL too old')
1135+
@unittest.skipIf(not IS_GRAALVM_SSL and ssl.OPENSSL_VERSION_INFO < (1, 0, 2, 0, 0), 'OpenSSL too old')
11321136
def test_get_ciphers(self):
11331137
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
11341138
ctx.set_ciphers('AESGCM')
@@ -3806,7 +3810,7 @@ def test_version_basic(self):
38063810
self.assertIs(s.version(), None)
38073811
self.assertIs(s._sslobj, None)
38083812
s.connect((HOST, server.port))
3809-
if IS_OPENSSL_1_1_1 and has_tls_version('TLSv1_3'):
3813+
if IS_GRAALVM_SSL or IS_OPENSSL_1_1_1 and has_tls_version('TLSv1_3'):
38103814
self.assertEqual(s.version(), 'TLSv1.3')
38113815
elif ssl.OPENSSL_VERSION_INFO >= (1, 0, 2):
38123816
self.assertEqual(s.version(), 'TLSv1.2')

0 commit comments

Comments
 (0)