">

python 2.7 TLS 설정


이 글은 클라이언트에서의 구현을 다룬다. 파라미터가 있어서 post 방식으로 사용한다.

헤더는 기존과 동일하게 작성하고, context를 하나 더 추가해준다. 


import httplib, ssl


headers = {Content-type": "application/x-www-form-urlencoded", "Aceept": "text/plain"}

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)

conn = httplib.HTTPSconnection('IP', 'prot', None, None, None, 10000, None, context)

conn.request("POST", "/url", params, headers)

response = conn.getresponse()

data = response.read()

conn.close


이렇게 하면 TLSv1.2로 구동되고 있는 서버와 통신이 문제 없이 된다.  

+ Recent posts