# SSL for HTTP and Python target on Windows

**URL:** https://community.haxe.org/t/ssl-for-http-and-python-target-on-windows/1798
**Category:** Haxe
**Tags:** haxe-python
**Created:** [June 9, 2019, 4:25pm UTC](https://community.haxe.org/t/ssl-for-http-and-python-target-on-windows/1798 "2019-06-09T16:25:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![supergeoff](https://community.haxe.org/user_avatar/community.haxe.org/supergeoff/32/600_2.png) [@supergeoff](https://community.haxe.org/u/supergeoff)
#### Post date: [June 9, 2019, 4:25pm UTC](https://community.haxe.org/t/ssl-for-http-and-python-target-on-windows/1798/1 "2019-06-09T16:25:08Z")

</div>

Hello all,  
I’ve noticed a changelog for Haxe Preview 3 stating that SSL support had been added for Python target.

My issue is related to HTTPS calls to API that does not provide certificates (you can try with Steam API).  
Here is the standard error regarding such request:

```haxe
__main__._HxException: SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')

```

That is a normal Python behavior since outputted code by Haxe does set the verification mode for the context used for HTTP request as “required”  
`context.verify_mode = python_lib_Ssl.CERT_REQUIRED`  
For a reminder default context created by SSL lib in python has  
verify\_mode set to CERT\_NONE. Thus by default Haxe output forces certificate verification.  
Since Preview 3 I assume, this has been changed and you can actually use a default context by specifying a python\_version \>= 3.4. This correctly set verify\_mode to CERT\_NONE…

But then here’s the error:

```haxe
  File "C:\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\Python37\lib\ssl.py", line 810, in _create
    raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

```

**Do you have any idea why such error?**

Especially when urllib does work and I was under the impression that it was the library used by the haxe.Http class…

```python
import urllib.request
response = urllib.request.urlopen(
    "https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid=440&count=3"
)
print(response.read())

```

Is it an issue to be opened on github?

Best regards;

---

<div class="post-metadata">

### Author: ![supergeoff](https://community.haxe.org/user_avatar/community.haxe.org/supergeoff/32/600_2.png) [@supergeoff](https://community.haxe.org/u/supergeoff)
#### Post date: [June 9, 2019, 10:03pm UTC](https://community.haxe.org/t/ssl-for-http-and-python-target-on-windows/1798/2 "2019-06-09T22:03:03Z")

</div>

Editing **python.net.SslSocket** like so:

```haxe
#if (python_version >= 3.4)
var context = Ssl.create_default_context(Purpose.SERVER_AUTH);

```

to

```haxe
#if (python_version >= 3.4)
var context = Ssl.create_default_context(Purpose.SERVER_AUTH);
context. check_hostname = false;

```

Solve the issue but I’m not sure of they implication related to certificates it might just be a dirty workaround…

Any ideas?

Best regards;
