[RustPython] sslError 클래스에 library, reason 속성 추가하기
목차
[RustPython] sslError 클래스에 library, reason 속성 추가하기 Add 'library', 'reason' Attribute to ssl.SSLError CPython 우선, 위 차이에서 RustPython에서 SSL 관련 에러가 발생했을때, ssl 모듈의 원인 분석에서 언급했듯이 SSLError를 생성하는 convert_openssl_error 함수를 수정한다. RustPython과 CPython이 출력하는 이해를 위해 쉽게 비교하자면 다음과 같다. CPython은 자체적으로 CPython은 OpenSSL이 갖고 있는 CPython은 이렇게 생성된 _ssl_data.h 를 활용해 ISSUE
Merged PR
개요
ssl.SSLError 클래스는 library와 reason 속성을 갖고있다. RustPython에는 아직 library와 reason 속성이 없는 상태이기 때문에, 이를 추가한 내용이다. 과정
1. 원인 분석
CPython
ssl.SSLError 속성['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'characters_written', 'errno', 'filename', 'filename2', 'library', 'reason', 'strerror', 'with_traceback'] RustPython
ssl.SSLError 속성['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'errno', 'filename', 'filename2', 'strerror', 'with_traceback']library와 reason 속성이 빠진 것을 확인할 수 있다.convert_openssl_error 함수에서 SSLError를 생성한다. 2. 수정
이 함수에는 에러 메시지 출력을 위해 library와 reason 값을 사용하고 있다. 이 함수에서 SSLError 클래스에 library, reason 속성을 추가하도록 변경했다. 
3. CPython의 SSLError
ssl.SSlError 메시지가 조금 달랐는데,
이는 사용하고 있는 library와 reason의 문자열 값이 조금 다르기 때문이다. CPython 출력 메시지 예시
ssl.SSLError: [X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found (_ssl.c:4293) RustPython 출력 메시지 예시
ssl.SSLError: [Errno 136] [x509 certificate routines] no certificate or crl found (ssl.rs:691) CPython
library -> "X509"
reason -> "NO_CERTIFICATE_OR_CRL_FOUND" RustPython
library -> "x509 certificate routines"
reason -> "136"library와 reason의 상수를 정의한 파일을 갖고있는데, 이는 RustPython이 값을 가져오는 방식과 조금 다르다.err.h, openssl.txt 등의 파일을 직접 파싱해서 _ssl_data.h로 만드는 모듈을 갖고 있고, OpenSSL의 내용이 업데이트될 때 해당 모듈을 실행해 CPython의 _ssl_data.h파일을 업데이트 하는 것으로 보인다. 다음 링크는 위에서 설명한 CPython이 갖고 있는 Python 모듈이다.SSLError에 필요한 library와 reason에 대한 문자열 값을 가져오도록 구현되어 있다.