Skip to content

Commit

Permalink
simplify ssl ca-certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Aug 14, 2024
1 parent 78e593b commit 5d11588
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 21 deletions.
59 changes: 49 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ manipulation configuration files. Bash for launching with Steam or Lutris or jus
* [Delca - Kitten Adventure](https://www.trle.net/sc/levelfeatures.php?lid=3379)


# test
# Prepare
This install the program in you're ".local" home directory
You need those, should be installed an desktop linux
You need those, should be installed on a desktop linux

* curl
* Qt5
Expand All @@ -41,26 +41,65 @@ To ensure that our application works properly right now, you need to download th
required certificates from Firefox and add them to your system’s certificate store.
Unfortunately, I cannot share these certificates directly.

Open Firefox go to trle.net and click the lock icon in the URL bar.
Click more info, click View Certificate then in the new window
there is a Miscellaneous section and 2 download links.

Change the name from
trle-net".pem" to trle-net".crt" so you'll have to

```
/etc/ssl/certs/trle-net-chain.pem
/etc/ssl/certs/trle-net.pem
/usr/share/ca-certificates/mozilla/trle-net-chain.crt
/usr/share/ca-certificates/mozilla/trle-net.crt
```
then add to /etc/ca-certificates.conf
```
mozilla/trle-net.crt
mozilla/trle-net-chain.crt
```
Something like that should work on you're system
you'll run:

```
update-ca-certificates
```
and you should see that you have those files as symbolic links.
Then it should work with curl.
```
sudo update-ca-certificates
/etc/ssl/certs/trle-net-chain.pem
/etc/ssl/certs/trle-net.pem
```

# Build

```shell
cmake -DCMAKE_INSTALL_PREFIX=~/.local .
make install
```

You can add maps to the database if you cd into utils
This should add Kitten Adventure Demo, but there is a bug
because the download link is not a zip file its a another html page.
# Use database

You can add maps to the database if you cd into utils.
This should add Kitten Adventure Demo.


If it don't work try installing the
python3 module from the error.
python3 module from the error, with pip

```shell
python3 getData.py https://www.trle.net/sc/levelfeatures.php?lid=3379

```

It will show
```
ERROR:The file at https://www.trle.net/scadm/trle_dl.php?lid=3379 is not a ZIP file. Content-Type: text/html
```
This means that you have to open the data.json file and add those values
```
"zipFileName": "",
"zipFileMd5": "",
"download_url": ""
```

```shell
python3 getData.py https://www.trle.net/sc/levelfeatures.php?lid=3379
Expand Down
2 changes: 1 addition & 1 deletion utils/addData.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def download_file(url, cert, file_name):
file_info = json.load(json_file)

zip_url = file_info.get('download_url')
cert = '/home/noisecode3/mySecretVirusFolder/trle-net-chain.pem'

cert = ('/etc/ssl/certs/ca-certificates.crt')
response = requests.get(zip_url, verify=cert)
zip_content = response.content

Expand Down
36 changes: 26 additions & 10 deletions utils/getData.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Set up logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s:%(message)s')
logging.getLogger("requests").setLevel(logging.DEBUG)
logging.getLogger("urllib3").setLevel(logging.DEBUG)
#logging.getLogger("urllib3").setLevel(logging.DEBUG)

if __name__ == "__main__":
if len(sys.argv) != 2:
Expand All @@ -32,10 +32,8 @@
sys.exit(1)

time.sleep(2)
# test url
# url = 'https://www.trle.net/sc/levelfeatures.php?lid=3573'

cert = '/home/noisecode3/mySecretVirusFolder/trle-net-chain.pem'
cert = ('/etc/ssl/certs/ca-certificates.crt')

try:
response = requests.get(url, verify=cert)
Expand Down Expand Up @@ -79,7 +77,7 @@
duration = "missing"
else:
duration = "missing"

specific_tags = soup.find_all('td', class_='medGText', align='left', valign='top')
body = specific_tags[1] if len(specific_tags) >= 2 else "missing"

Expand All @@ -98,11 +96,29 @@
try:
response2 = requests.head(url, verify=cert, allow_redirects=True)
response2.raise_for_status()
download_url = response2.url
file_name = response2.url.split('/')[-1]
zipFileName = file_name
md5_checksum = hashlib.md5(requests.get(url, verify=cert).content).hexdigest()
zipFileMd5 = md5_checksum

# Check if the content type is a zip file
if 'Content-Type' in response2.headers and response2.headers['Content-Type'] == 'application/zip':
download_url = response2.url
file_name = response2.url.split('/')[-1]
zipFileName = file_name

# Download the file and calculate its MD5 checksum
response3 = requests.get(url, verify=cert)
response3.raise_for_status() # Check again to ensure the GET request is successful
md5_checksum = hashlib.md5(response3.content).hexdigest()
zipFileMd5 = md5_checksum

# Do something with the download URL, file name, and MD5 checksum
print(f"Download URL: {download_url}")
print(f"File Name: {zipFileName}")
print(f"MD5 Checksum: {zipFileMd5}")
else:
logging.error(f"The file at {url} is not a ZIP file. Content-Type: {response2.headers.get('Content-Type')}")
download_url = ''
zipFileName = ''
zipFileMd5 = ''

except requests.exceptions.RequestException as e:
logging.error(f"Failed to retrieve file information from {url}: {e}")

Expand Down

0 comments on commit 5d11588

Please sign in to comment.