def test_assert_specific_hostname(self): with HTTPSConnectionPool( "localhost", self.port, cert_reqs="CERT_REQUIRED", ca_certs=DEFAULT_CA ) as https_pool: https_pool.assert_hostname = "localhost" https_pool.request("GET", "/")
def test_simple(self): with HTTPSConnectionPool(self.host, self.port, ca_certs=DEFAULT_CA) as https_pool: r = https_pool.request("GET", "/") assert r.status == 200, r.data
def setup_method(self, method): self._pool = HTTPSConnectionPool(self.host, self.port, ca_certs=DEFAULT_CA)
try: https_pool.request('GET', '/') self.fail("Didn't raise SSL error with no CA") except SSLError, e: self.assertTrue('No root certificates' in str(e)) https_pool.ca_certs = DEFAULT_CA_BAD try: https_pool.request('GET', '/') self.fail("Didn't raise SSL error with wrong CA") except SSLError, e: self.assertTrue('certificate verify failed' in str(e)) https_pool.ca_certs = DEFAULT_CA https_pool.request('GET', '/') # Should succeed without exceptions. https_fail_pool = HTTPSConnectionPool('127.0.0.1', self.port, cert_reqs='CERT_REQUIRED') https_fail_pool.ca_certs = DEFAULT_CA try: https_fail_pool.request('GET', '/') self.fail("Didn't raise SSL invalid common name") except SSLError, e: self.assertTrue("doesn't match" in str(e)) if __name__ == '__main__': unittest.main()
def setUp(self): self._pool = HTTPSConnectionPool(self.host, self.port) self.addCleanup(self._pool.close)
def __init__(self): self.session = HTTPSConnectionPool(API_HOST) self.ThreadedRequest = ThreadedRequest
def test_ssl_unverified_with_ca_certs(self): https_pool = HTTPSConnectionPool(self.host, self.port, cert_reqs='CERT_NONE') https_pool.ca_certs = DEFAULT_CA_BAD https_pool.request('GET', '/')
from socket import * import sys import random import os import time from urllib3 import HTTPSConnectionPool serverHost = 'mingf.ddns.net' serverPort = 9999 numTrials = 2 numWritesReads = 300 method = 'POST' path = '/' pool = HTTPSConnectionPool(serverHost, serverPort, ca_certs='./signer.crt') RECV_TOTAL_TIMEOUT = 0.1 RECV_EACH_TIMEOUT = 0.01 a = time.time() socketList = [] for i in xrange(numTrials): for j in xrange(numWritesReads): s = pool.request(method, path) socketList.append(s) for s in socketList: if s.status == 200: print 'Success!'
def setUp(self): self._pool = HTTPSConnectionPool(self.host, self.port, ca_certs=DEFAULT_CA) self.addCleanup(self._pool.close)
def test_dotted_fqdn(self): pool = HTTPSConnectionPool(self.host + ".", self.port, ca_certs=DEFAULT_CA) r = pool.request("GET", "/") self.assertEqual(r.status, 200, r.data)
def test_no_ssl(self): pool = HTTPSConnectionPool(self.host, self.port) pool.ConnectionCls = None self.addCleanup(pool.close) self.assertRaises(SSLError, pool._new_conn) self.assertRaises(SSLError, pool.request, 'GET', '/')
def open(self, cx_data): self.pool = HTTPSConnectionPool(host=cx_data["host"], port=cx_data["port"], cert_reqs="CERT_NONE", ca_certs=where()) self.headers = make_headers(basic_auth=":".join(cx_data["auth"]))
def __init__(self, api_key): self.handle = HTTPSConnectionPool(RapleafApi.HOST, timeout=RapleafApi.TIMEOUT) self.base_path = RapleafApi.BASE_PATH + '?api_key=%s' % (api_key)
def test_dotted_fqdn(self): with HTTPSConnectionPool(self.host + ".", self.port, ca_certs=DEFAULT_CA) as pool: r = pool.request("GET", "/") assert r.status == 200, r.data
def test_verified_without_ca_certs(self): https_pool = HTTPSConnectionPool(self.host, self.port, cert_reqs='CERT_REQUIRED') self.assertRaises(SSLError, https_pool.request, 'GET', '/')
def test_dotted_fqdn(self): pool = HTTPSConnectionPool(self.host + '.', self.port) r = pool.request('GET', '/') self.assertEqual(r.status, 200, r.data)
def new_pool(timeout, cert_reqs='CERT_REQUIRED'): https_pool = HTTPSConnectionPool(TARPIT_HOST, self.port, timeout=timeout, cert_reqs=cert_reqs) return https_pool
def setUp(self): self._pool = HTTPSConnectionPool(self.host, self.port)
conf.target_port) # disable urllib'3 SSL warning (globally) urllib3.disable_warnings() # Benchmark target host if conf.proxy_url: database.connection_pool = ProxyManager( conf.proxy_url, timeout=conf.fetch_timeout_secs, maxsize=conf.thread_count, cert_reqs='CERT_NONE') elif not conf.proxy_url and is_ssl: database.connection_pool = HTTPSConnectionPool( resolved, port=str(port), timeout=conf.fetch_timeout_secs, maxsize=conf.thread_count) else: database.connection_pool = HTTPConnectionPool( resolved, port=str(port), timeout=conf.fetch_timeout_secs, maxsize=conf.thread_count) # Vhost forgery if conf.forge_vhost != '<host>': conf.target_host = conf.forge_vhost if conf.json_output: SelectedPrintWorker = JSONPrintResultWorker
def test_set_cert_default_cert_required(self): pool = HTTPSConnectionPool(self.host, self.port, ca_certs=DEFAULT_CA) self.assertEqual(pool.ssl_context.verify_mode, ssl.CERT_REQUIRED)
def __init__(self): self.handle = HTTPSConnectionPool(RapleafApi.host, timeout = RapleafApi.timeout)