Skip to content

Commit

Permalink
ctx ssl add minimum_version staciax#57
Browse files Browse the repository at this point in the history
  • Loading branch information
staciax committed Jun 14, 2022
1 parent 8ddd586 commit 1bee909
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions utils/valorant/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,18 @@ def _extract_tokens_from_uri(URL: str) -> Optional[Tuple[str, Any]]:
'RSA+3DES',
]


class ClientSession(aiohttp.ClientSession):
def __init__(self, *args, **kwargs):
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ctx.minimum_version = ssl.TLSVersion.TLSv1_3
ctx.set_ciphers(':'.join(FORCED_CIPHERS))
# ctx.protocol = ssl.PROTOCOL_TLSv1 | ssl.PROTOCOL_TLSv1_1 | ssl.PROTOCOL_TLSv1_2 | ssl.PROTOCOL_TLSv1_3
super().__init__(
*args,
**kwargs,
cookie_jar=aiohttp.CookieJar(),
connector=aiohttp.TCPConnector(ssl=ctx)
)


class Auth:
def __init__(self) -> None:
self._headers: Dict = {
Expand Down Expand Up @@ -321,21 +319,9 @@ async def login_with_cookie(self, cookies: Dict) -> Dict[str, Any]:

cookie_payload = f'ssid={cookies};' if cookies.startswith('e') else cookies

class CookieClientSession(aiohttp.ClientSession):
def __init__(self, *args, **kwargs):
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ctx.set_ciphers("DEFAULT@SECLEVEL=1")
super().__init__(
*args,
**kwargs,
connector=aiohttp.TCPConnector(ssl=ctx),
headers=MultiDict({
"Accept-Language": "en-US,en;q=0.9",
"Accept": "application/json, text/plain, */*",
'cookie': cookie_payload,
}))

session = CookieClientSession()
self._headers['cookie'] = cookie_payload

session = ClientSession()

r = await session.get(
"https://auth.riotgames.com/authorize"
Expand All @@ -345,6 +331,7 @@ def __init__(self, *args, **kwargs):
"&scope=account%20openid"
"&nonce=1",
allow_redirects=False,
headers=self._headers
)
if r.status != 303:
raise AuthenticationError(local_response.get('FAILED'))
Expand Down

0 comments on commit 1bee909

Please sign in to comment.