Improve the ssl connection handle log message. 25/9525/4
authordliu5 <david.liu@windriver.com>
Tue, 8 Nov 2022 05:41:38 +0000 (13:41 +0800)
committerdliu5 <david.liu@windriver.com>
Tue, 8 Nov 2022 08:25:12 +0000 (16:25 +0800)
Fix auth header exception handling to avoid 500.

Signed-off-by: dliu5 <david.liu@windriver.com>
Change-Id: I7fb0d11584f6e575ba891a51bebd7631faef7505

o2common/authmw/authmiddleware.py
o2ims/service/command/notify_alarm_handler.py
o2ims/service/command/notify_handler.py
o2ims/service/command/registration_handler.py

index 13be910..032e735 100644 (file)
@@ -61,8 +61,7 @@ class authmiddleware():
         logger.info(__name__ + 'authentication middleware')
         req = Request(environ, populate_request=True, shallow=True)
         try:
-            auth_header = req.headers['Authorization']
-
+            auth_header = req.headers.get('Authorization', None)
             if auth_header:
                 auth_token = auth_header.split(" ")[1]
 
index 11729a4..b4e22a1 100644 (file)
@@ -69,8 +69,9 @@ def callback_smo(sub: AlarmSubscription, msg: AlarmEvent2SMO):
             return
         logger.error('Notify alarm Response code is: {}'.format(status))
     except ssl.SSLCertVerificationError as e:
-        logger.info(
-            'Notify alarm post data with trusted ca failed: {}'.format(e))
+        logger.debug(
+            'Notify alarm try to post data with trusted ca \
+                failed: {}'.format(e))
         if 'self signed' in str(e):
             conn = get_https_conn_selfsigned(o.netloc)
             try:
index fe22f2a..8f134af 100644 (file)
@@ -102,7 +102,8 @@ def callback_smo(sub: Subscription, msg: Message2SMO):
             return
         logger.error('Notify Response code is: {}'.format(status))
     except ssl.SSLCertVerificationError as e:
-        logger.info('Notify post data with trusted ca failed: {}'.format(e))
+        logger.debug(
+            'Notify try to post data with trusted ca failed: {}'.format(e))
         if 'self signed' in str(e):
             conn = get_https_conn_selfsigned(o.netloc)
             try:
index aead4cc..c144405 100644 (file)
@@ -108,7 +108,8 @@ def call_smo(reg_data: dict):
     try:
         return post_data(conn, o.path, callback_data)
     except ssl.SSLCertVerificationError as e:
-        logger.info('Register to smo with trusted ca failed: {}'.format(e))
+        logger.debug('Try to register to smo with \
+        trusted ca failed: {}'.format(e))
         if 'self signed' in str(e):
             conn = get_https_conn_selfsigned(o.netloc)
             try: