# Path: shippo/error.py
# class ShippoError(Exception):
# class APIError(ShippoError):
# class APIConnectionError(ShippoError):
# class AddressError(ShippoError):
# class InvalidRequestError(ShippoError):
# class AuthenticationError(ShippoError):
#     def __init__(self, message=None, http_body=None, http_status=None,
#                  json_body=None):
#     def __init__(self, message, param, code, http_body=None,
#                  http_status=None, json_body=None):
#     def __init__(self, message, param, http_body=None,
#                  http_status=None, json_body=None):
# 
# Path: shippo/http_client.py
# def new_default_http_client(*args, **kwargs):
#     def __init__(self, verify_ssl_certs=True):
#     def request(self, method, url, headers, post_data=None):
#     def request(self, method, url, headers, post_data=None):
#     def _handle_request_error(self, e):
#     def request(self, method, url, headers, post_data=None):
#     def _handle_request_error(self, e, url):
# class HTTPClient(object):
# class RequestsClient(HTTPClient):
# class UrlFetchClient(HTTPClient):
# 
# Path: shippo/util.py

# 
# Path: shippo/certificate_blacklist.py
# BLACKLISTED_DIGESTS = {
# }
# def verify(hostname, certificate):
# 
# Path: shippo/version.py
# VERSION = '2.1.2'


import calendar
import datetime
import os
import platform
import socket
import ssl
import time
import urllib.parse
import warnings
import shippo
from shippo import error, http_client, util, certificate_blacklist
from shippo.version import VERSION
        from shippo.config import verify_ssl_certs
        from shippo.config import api_version
            from shippo.config import api_key
        from shippo.config import verify_ssl_certs

        Unfortunately the interface to OpenSSL doesn't make it easy to check
        the certificate before sending potentially sensitive data on the wire.
        This approach raises the bar for an attacker significantly."""


        if verify_ssl_certs and not self._CERTIFICATE_VERIFIED:
            uri = urllib.parse.urlparse(shippo.config.api_base)
            try:
                certificate = ssl.get_server_certificate(
                    (uri.hostname, uri.port or 443))
                der_cert = ssl.PEM_cert_to_DER_cert(certificate)
            except socket.error as e:
                raise error.APIConnectionError(e)
            except TypeError:
                # The Google App Engine development server blocks the C socket
                # module which causes a type error when using the SSL library
                if ('APPENGINE_RUNTIME' in os.environ and
                        'Dev' in os.environ.get('SERVER_SOFTWARE', '')):
                    self._CERTIFICATE_VERIFIED = True
                    warnings.warn(
                        'We were unable to verify Shippo\'s SSL certificate '
                        'due to a bug in the Google App Engine development '
                        'server. Please alert us immediately at '
                        'suppgoshippo.compo.com if this message appears in your '
                        'production logs.')
                    return
                else:
                    raise


# Path: shippo/error.py
# class ShippoError(Exception):
# class APIError(ShippoError):
# class APIConnectionError(ShippoError):
# class AddressError(ShippoError):
# class InvalidRequestError(ShippoError):
# class AuthenticationError(ShippoError):
#     def __init__(self, message=None, http_body=None, http_status=None,
#                  json_body=None):
#     def __init__(self, message, param, code, http_body=None,
#                  http_status=None, json_body=None):
#     def __init__(self, message, param, http_body=None,
#                  http_status=None, json_body=None):
# 
# Path: shippo/http_client.py
# def new_default_http_client(*args, **kwargs):
#     def __init__(self, verify_ssl_certs=True):
#     def request(self, method, url, headers, post_data=None):
#     def request(self, method, url, headers, post_data=None):
#     def _handle_request_error(self, e):
#     def request(self, method, url, headers, post_data=None):
#     def _handle_request_error(self, e, url):
# class HTTPClient(object):
# class RequestsClient(HTTPClient):
# class UrlFetchClient(HTTPClient):
# 
# Path: shippo/util.py

# 
# Path: shippo/certificate_blacklist.py
# BLACKLISTED_DIGESTS = {
# }
# def verify(hostname, certificate):
# 
# Path: shippo/version.py
# VERSION = '2.1.2'


# Path: shippo/api_requestor.py
import calendar
import datetime
import os
import platform
import socket
import ssl
import time
import urllib.parse
import warnings
import shippo
from shippo import error, http_client, util, certificate_blacklist
from shippo.version import VERSION
        from shippo.config import verify_ssl_certs
        from shippo.config import api_version
            from shippo.config import api_key
        from shippo.config import verify_ssl_certs


        Unfortunately the interface to OpenSSL doesn't make it easy to check
        the certificate before sending potentially sensitive data on the wire.
        This approach raises the bar for an attacker significantly."""


        if verify_ssl_certs and not self._CERTIFICATE_VERIFIED:
            uri = urllib.parse.urlparse(shippo.config.api_base)
            try:
                certificate = ssl.get_server_certificate(
                    (uri.hostname, uri.port or 443))
                der_cert = ssl.PEM_cert_to_DER_cert(certificate)
            except socket.error as e:
                raise error.APIConnectionError(e)
            except TypeError:
                # The Google App Engine development server blocks the C socket
                # module which causes a type error when using the SSL library
                if ('APPENGINE_RUNTIME' in os.environ and
                        'Dev' in os.environ.get('SERVER_SOFTWARE', '')):
                    self._CERTIFICATE_VERIFIED = True
                    warnings.warn(
                        'We were unable to verify Shippo\'s SSL certificate '
                        'due to a bug in the Google App Engine development '
                        'server. Please alert us immediately at '
                        'suppgoshippo.compo.com if this message appears in your '
                        'production logs.')
                    return
                else:
                    raise


            self._CERTIFICATE_VERIFIED = certificate_blacklist.verify(