# Issue with urllib2 python package - no SNI within HTTPS request

**URL:** <https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [November 5, 2018, 10:36am UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694 "2018-11-05T10:36:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bibiak](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@bibiak](https://forums.plex.tv/u/bibiak)\
**Post date:** [November 5, 2018, 10:36am UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694/1 "2018-11-05T10:36:06Z")

</div>

Hi,

since couple of days there’s no posibility to run HTML.ElementFromURL for CloudFlare servers.

Log from plugin:  
2018-11-05 11:18:42,009 (7feb0a676700) : CRITICAL (runtime:889) - Exception (most recent call last):  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py”, line 843, in handle\_request  
result = f(\*\*d)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/Plug-ins/Serialnet.bundle/Contents/Code/ **init**.py”, line 45, in GetShows  
page = HTML.ElementFromURL(main\_url,errors=‘replace’,encoding=‘utf-8’,timeout=90,cacheTime=3600\*12)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/parsekit.py”, line 482, in ElementFromURL  
method=method,  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py”, line 67, in \_http\_request  
req = self.\_core.networking.http\_request(url, \*args, \*\*kwargs)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py”, line 370, in http\_request  
return HTTPRequest(self.\_core, url, data, h, url\_cache, encoding, errors, timeout, immediate, sleep, opener, follow\_redirects, method)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py”, line 141, in **init**  
self.load()  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py”, line 181, in load  
f = self.\_opener.open(req, timeout=self.\_timeout)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 444, in open  
response = meth(req, response)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 557, in http\_response  
‘http’, request, response, code, msg, hdrs)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 476, in error  
result = self.\_call\_chain(\*args)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 416, in \_call\_chain  
result = func(\*args)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py”, line 96, in http\_error\_301  
result = urllib2.HTTPRedirectHandler.http\_error\_301(self, req, fp, code, msg, headers)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 652, in http\_error\_302  
return self.parent.open(new, timeout=req.timeout)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 438, in open  
response = self.\_open(req, data)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 456, in \_open  
‘\_open’, req)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 416, in \_call\_chain  
result = func(\*args)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 1225, in https\_open  
return self.do\_open(httplib.HTTPSConnection, req)  
File “/share/CACHEDEV2\_DATA/.qpkg/PlexMediaServer/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Platforms/Shared/Libraries/urllib2\_new.py”, line 1192, in do\_open  
raise URLError(err)  
URLError: \<urlopen error [SSL: SSLV3\_ALERT\_HANDSHAKE\_FAILURE] sslv3 alert handshake failure (\_ssl.c:590)\>

openssl checks:

1. without servername:  
~\> openssl s\_client -connect serialnet.pl:443  
CONNECTED(00000003)  
139779610109840:error:14077410:SSL routines:SSL23\_GET\_SERVER\_HELLO:sslv3 alert handshake failure:s23\_clnt.c:769:

* * *

## no peer certificate available

## No client certificate CA names sent

## SSL handshake has read 7 bytes and written 289 bytes

## New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None Krb5 Principal: None PSK identity: None PSK identity hint: None Start Time: 1541413940 Timeout : 300 (sec) Verify return code: 0 (ok)

1. with servername:  
~\>  
openssl s\_client -connect serialnet.pl:443 -servername serialnet.pl  
CONNECTED(00000003)  
…  
subject=/OU=Domain Control Validated/OU=PositiveSSL Multi-Domain/CN=[sni46361.cloudflaressl.com](http://sni46361.cloudflaressl.com)  
issuer=/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO ECC Domain Validation Secure Server CA 2

* * *

## No client certificate CA names sent Peer signing digest: SHA256 Server Temp Key: ECDH, P-256, 256 bits

## SSL handshake has read 5296 bytes and written 436 bytes

New, TLSv1/SSLv3, Cipher is ECDHE-ECDSA-AES128-GCM-SHA256  
Server public key is 256 bit  
Secure Renegotiation IS supported  
Compression: NONE  
Expansion: NONE  
No ALPN negotiated  
SSL-Session:  
Protocol : TLSv1.2  
Cipher : ECDHE-ECDSA-AES128-GCM-SHA256  
Session-ID: D0FE56D51530E7558B55D8FB43B1D8008BEA2D9F981D20B119DB1B4F03E3A2DF  
Session-ID-ctx:  
Master-Key: 734EFF1D98E66D96564D9C730B57571DD3C2DA7CF5005C3136C6EA9EAA75412A24FF269AB2456E6CC24D9A90CD5CC227  
Key-Arg : None  
Krb5 Principal: None  
PSK identity: None  
PSK identity hint: None  
TLS session ticket lifetime hint: 64800 (seconds)  
TLS session ticket:  
0000 - 00 58 32 d8 08 f6 d4 06-86 f1 fb 82 0c d9 17 b3 .X2…  
0010 - e6 2b 53 f8 b3 20 7c 57-a4 5c 1a db 8d fd a4 f0 .+S… |W…  
0020 - 62 d8 4e d5 8f 14 eb 09-18 da ae cb c4 2e 4e 2a b.N…N\*  
0030 - 43 d4 2f 0b 16 10 52 15-b2 2b 58 f8 c9 de 76 34 C./…R…+X…v4  
0040 - 1c ca 48 20 17 d2 fe 51-5e 8d e0 b5 f5 48 ff 8a …H …Q^…H…  
0050 - d1 39 25 9b cd 92 2b e0-09 58 a6 58 8e d7 ce f3 .9%…+…X.X…  
0060 - 7c bd 11 19 32 03 65 c9-b4 82 8f d3 6c dd 0c 34 |…2.e…l…4  
0070 - 14 3e 32 a2 4e 73 8f 9d-58 ba bc a5 6d 2a a9 22 .\>2.Ns…X…m\*."  
0080 - a2 e7 17 07 e8 11 73 d1-2f 7e 5a 91 fb a0 d2 fc …s./~Z…  
0090 - ea a1 b3 32 c3 ae 98 96-fb aa bd d5 6e 82 8b 71 …2…n…q  
00a0 - 87 b7 dd c6 5b 4d c0 fa-61 8c 37 22 fb 35 b1 01 …[M…a.7".5…

```
Start Time: 1541413962
Timeout : 300 (sec)
Verify return code: 0 (ok)

```

* * *

DONE

Do I have to wait until Plex introduce new version of Python or urllib2 components or there’s workaround that can be implemented?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [November 5, 2018, 8:56pm UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694/2 "2018-11-05T20:56:41Z")

</div>

> [@bibiak](#):
>
> Do I have to wait until Plex introduce new version of Python or urllib2 components or there’s workaround that can be implemented?

First of all, next time, please format your post with `code` tags to make reading a tad more easy

And now for your Q:

PMS is running Python V 2.7.12, and this issue was AFAICT fixed in V2.7.13  
[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=878232](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=878232)

When that’s said, I would not expect an update to PMS for this, since Plex is phasing out the framework!  
[https://www.plex.tv/blog/subtitles-and-sunsets-big-improvements-little-housekeeping/](https://www.plex.tv/blog/subtitles-and-sunsets-big-improvements-little-housekeeping/)

---

<div class="post-metadata">

**Author:** ![bibiak](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@bibiak](https://forums.plex.tv/u/bibiak)\
**Post date:** [November 6, 2018, 8:02am UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694/3 "2018-11-06T08:02:23Z")

</div>

Sorry for that it’s code thing - I’m new to that community and just wanted to ask one question. Isn’t it possible to implement new Python before sunset?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [November 6, 2018, 11:31am UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694/4 "2018-11-06T11:31:23Z")

</div>

It took almost 3 years to het it updated to v12 😉

I’m about 99.99 % sure Plex do not wanna rock the boat, when it’s heading towards EOL

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [February 4, 2019, 11:42am UTC](https://forums.plex.tv/t/issue-with-urllib2-python-package-no-sni-within-https-request/327694/5 "2019-02-04T11:42:31Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
