0
votes

I am trying log to AWS cloud watch and I am getting this error. same code was working all from yesterday without issues. I looked into some article and I installed certifi package as well but this also did not help

I am using Python 3.5 and watchtower to log data to AWS cloud watch. I am running my python code in windows 10 OS.

Can you please help me with this?


Traceback (most recent call last): File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen chunked=chunked, File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request self._validate_conn(conn) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 976, in validate_conn conn.connect() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connection.py", line 370, in connect ssl_context=context, File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\util\ssl.py", line 377, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 376, in wrap_socket _context=self) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 747, in init self.do_handshake() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 983, in do_handshake self._sslobj.do_handshake() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 628, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\httpsession.py", line 263, in send chunked=self._chunked(request.headers), File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 725, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\util\retry.py", line 379, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\packages\six.py", line 734, in reraise raise value.with_traceback(tb) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen chunked=chunked, File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request self.validate_conn(conn) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 976, in validate_conn conn.connect() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connection.py", line 370, in connect ssl_context=context, File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\util\ssl.py", line 377, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 376, in wrap_socket context=self) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 747, in init self.do_handshake() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 983, in do_handshake self.sslobj.do_handshake() File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\ssl.py", line 628, in do_handshake self.sslobj.do_handshake() urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (ssl.c:646) During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".\test_main.py", line 2, in import test_provision_api File "C:\Users\BBB\Documents\Drive D\GIT_Local\NBNBNN\Python_Logging\V2.1\test_provision_api.py", line 39, in obj_PdAdmin.call_provisionadmin(pv_url1, WssVersion_list[0], master_AffId[0], master_Culture[0]) File "C:\Users\BBB\Documents\Drive D\GIT_Local\NBNBNN\Python_Logging\V2.1\test_provision_api.py", line 26, in call_provisionadmin HttpJsonlogger.info('PD Admin - /ProductDefinition', extra=pd_admin_extra) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\logging_init.py", line 1279, in info self.log(INFO, msg, args, **kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\logging_init.py", line 1415, in log self.handle(record) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\logging_init.py", line 1425, in handle self.callHandlers(record) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\logging_init.py", line 1487, in callHandlers hdlr.handle(record) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\logging_init.py", line 855, in handle self.emit(record) File "C:\Users\BBB\AppData\Roaming\Python\Python35\site-packages\watchtower_init.py", line 174, in emit logStreamName=stream_name) File "C:\Users\BBB\AppData\Roaming\Python\Python35\site-packages\watchtower_init.py", line 20, in _idempotent_create _callable(args, **kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\client.py", line 316, in _api_call return self._make_api_call(operation_name, kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\client.py", line 622, in _make_api_call operation_model, request_dict, request_context) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\client.py", line 641, in _make_request return self._endpoint.make_request(operation_model, request_dict) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\endpoint.py", line 102, in make_request return self._send_request(request_dict, operation_model) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\endpoint.py", line 137, in _send_request success_response, exception): File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\endpoint.py", line 256, in _needs_retry caught_exception=caught_exception, request_dict=request_dict) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\hooks.py", line 356, in emit return self._emitter.emit(aliased_event_name, **kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\hooks.py", line 228, in emit return self._emit(event_name, kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\hooks.py", line 211, in _emit response = handler(kwargs) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 183, in call if self._checker(attempts, response, caught_exception): File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 251, in call caught_exception) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry return self._checker(attempt_number, response, caught_exception) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 317, in call caught_exception) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 223, in call attempt_number, caught_exception) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exception raise caught_exception File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\endpoint.py", line 200, in _do_get_response http_response = self._send(request) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\endpoint.py", line 269, in _send return self.http_session.send(request) File "C:\Users\BBB\AppData\Local\Programs\Python\Python35\lib\site-packages\botocore\httpsession.py", line 281, in send raise SSLError(endpoint_url=request.url, error=e) botocore.exceptions.SSLError: SSL validation failed for https://logs.-**-.amazonaws.com/ [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)

1

1 Answers

0
votes

I don't know the specific about your case but certificate validation always end up with the following solutions:

  • the certificate is expired
  • the certificate is not trusted because you don't have the public key or the certificate authority in your trust file/truststore
  • the domain is not covered by the certificate

The message provided seems to tell the domain https://logs.-**-.amazonaws.com is not covered by the certificate

So download the certificate, get the details and check if:

  • "Delivered to" field cover the domain name
  • one of "Subject Alternative Name (SAN)" cover the domain name

EDIT:

To download the certificate either use a browser to load the url and use the "lock" icon to download the certificate or use openssl utility to download the certificate from the url. To get the details, save the certificate with the ".cer" extension and double click on it or use openssl utility to get the details from a certificate file.

Good luck