def _get_server_cert(self, response):
if self.send_cbt:<EOL><INDENT>certificate_hash = None<EOL>raw_response = response.raw<EOL>if isinstance(raw_response, HTTPResponse):<EOL><INDENT>if sys.version_info > (<NUM_LIT:3>, <NUM_LIT:0>):<EOL><INDENT>socket = raw_response._fp.fp.raw._sock<EOL><DEDENT>else:<EOL><INDENT>socket = raw_response._fp.fp._sock<EOL><DEDENT>try:<EOL><INDENT>server_certificate = socket.getpeercert(True)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>certificate_hash = _get_certificate_hash(server_certificate)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>",<EOL>NoCertificateRetrievedWarning)<EOL><DEDENT>return certificate_hash<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Get the certificate at the request_url and return it as a hash. Will get the raw socket from the
original response from the server. This socket is then checked if it is an SSL socket and then used to
get the hash of the certificate. The certificate hash is then used with NTLMv2 authentication for
Channel Binding Tokens support. If the raw object is not a urllib3 HTTPReponse (default with requests)
then no certificate will be returned.

:param response: The original 401 response from the server
:return: The hash of the DER encoded certificate at the request_url or None if not a HTTPS endpoint