Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Use custom ciphers
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudiuGeorgiu committed Oct 30, 2020
1 parent 0afca44 commit bb5f59a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Test on Python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
max-parallel: 1
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Test on Python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
max-parallel: 1
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Test on Python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
max-parallel: 1
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8.2-slim-buster
FROM python:3.9.0-slim-buster

WORKDIR /app/

Expand Down
45 changes: 45 additions & 0 deletions playstore/playstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,62 @@
import json
import logging
import os
import platform
import re
import sys
from typing import Iterable

import requests
import requests.packages.urllib3.util.ssl_
from google.protobuf import json_format
from requests.exceptions import ChunkedEncodingError

from playstore import playstore_proto_pb2 as playstore_protobuf
from playstore.credentials import EncryptedCredentials
from playstore.util import Util

# Detect Python version and set the SSL ciphers accordingly. This is needed to avoid
# login errors with some versions of Python even if correct credentials are used. If
# you are still getting login errors, try different cipher combinations: the following
# should work on GitHub Actions runners, but they might not work on different machines.
# PlaystoreDownloader works best on Linux and Docker, and in such case no cipher
# modification should be needed.

if sys.version_info < (3, 6):
raise RuntimeError("This version of Python is not supported anymore")
elif sys.version_info.major == 3 and sys.version_info.minor == 6:
if platform.system() == "Windows":
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = (
"ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:"
"DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:!aNULL:!MD5"
)
elif sys.version_info.major == 3 and (
sys.version_info.minor == 7 or sys.version_info.minor == 8
):
if platform.system() == "Windows":
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = (
"ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20:ECDH+AESGCM:DH+AESGCM:"
"ECDH+AES:DH+AES:RSA+AESGCM:RSA+AES:!DSS"
)
elif platform.system() == "Darwin":
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = (
"ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:"
"DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:!aNULL:!MD5"
)
elif sys.version_info.major == 3 and sys.version_info.minor == 9:
if platform.system() == "Windows":
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = (
"ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20:ECDH+AESGCM:DH+AESGCM:"
"ECDH+AES:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!eNULL:!MD5:!DSS"
)
elif platform.system() == "Darwin":
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = (
"ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:"
"DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:!aNULL:!MD5"
)
else:
raise RuntimeError("This version of Python is not supported yet")


class Playstore(object):

Expand Down

0 comments on commit bb5f59a

Please sign in to comment.