Closed Narengowda closed 7 years ago
Stackoverflow link: https://stackoverflow.com/questions/45293922/hyper-http2-custom-sslcontext-error
If you are using a custom SSLContext you must set it up appropriately for HTTP/2. This involves setting some protocol negotiation parameters. You should begin by obtaining your SSLContext
using this function, which you can then subsequently modify to suit your needs.
import ssl
import hyper
from hyper.tls import init_context
ssl_context = init_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
conn = hyper.HTTP20Connection('http2.akamai.com', port=443, ssl_context=ssl_context)
conn.request('GET', '/')
print conn.get_response()
@Kostya Your example worked fine but below scenario is still a problem.
ev-www.opentable.com.edgekey.net - server with virtual hosting servers based on "Host" header, I am still getting the error. Also let me know how to update SNI
ssl_context = init_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_OPTIONAL
headers={'Host': 'www.opentable.com'}
conn = hyper.HTTP20Connection('ev-www.opentable.com.edgekey.net', port=443, ssl_context=ssl_context)
conn.request('GET', '/washington-dc-restaurants', headers=headers)
print conn.get_response()
I am trying to make HTTP2 request to a server(virtual hosted) which gives SSL certificates based on host header value(SNI).
Hyper-h2 package for Python won't support SNI or disabling cert verification! https://hyper.readthedocs.io/en/latest/advanced.html#ssl-tls-certificate-verification
One way to disable certs verification is by having custom SSLContext, and stuck in protocol assertion error
Basic code to make HTTP2 call with custom SSLContext:
Error :