python-syslogssl
python-syslogssl copied to clipboard
AttributeError: 'SSLSysLogHandler' object has no attribute 'socket'
Here is my test.py code-
import logging
import socket
from syslogssl import SSLSysLogHandler
host = '10.140.7.251'
port = 6514 # default, you'll want to change this to your port
address = (host, port)
# We don't want this to hang
socket.setdefaulttimeout(5.0)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
syslog = SSLSysLogHandler(address=address, certs='/etc/ssl/rsyslog/THRALL-certificate.crt')
logger.addHandler(syslog)
logger.info('testing SSLSysLogHandler')
I am not sure about the unknown error and also, AttributeError: 'SSLSysLogHandler' object has no attribute 'socket'. Error stacktrace-
root (master *):[/home/admin/scripts/python-syslogssl]
$ python test.py
Traceback (most recent call last):
File "test.py", line 14, in <module>
syslog = SSLSysLogHandler(address=address, certs='/etc/ssl/rsyslog/THRALL-certificate.crt')
File "/home/admin/scripts/python-syslogssl/syslogssl.py", line 115, in __init__
cert_reqs=ssl.CERT_REQUIRED)
File "/usr/lib/python2.7/ssl.py", line 933, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 542, in __init__
self._context.load_verify_locations(ca_certs)
ssl.SSLError: unknown error (_ssl.c:2831)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1669, in shutdown
h.close()
File "/home/admin/scripts/python-syslogssl/syslogssl.py", line 122, in close
self.socket.close()
AttributeError: 'SSLSysLogHandler' object has no attribute 'socket'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/logging/__init__.py", line 1669, in shutdown
h.close()
File "/home/admin/scripts/python-syslogssl/syslogssl.py", line 122, in close
self.socket.close()
AttributeError: 'SSLSysLogHandler' object has no attribute 'socket'
I created .crt from my .pem file this way-
openssl x509 -outform der -in THRALL-cert.pem -out THRALL-certificate.crt
Ref: StackOverflow