Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download CA from Tonies Server #268

Open
SciLor opened this issue Dec 4, 2024 · 1 comment
Open

Download CA from Tonies Server #268

SciLor opened this issue Dec 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@SciLor
Copy link
Contributor

SciLor commented Dec 4, 2024

Use teddyCloud to download the Boxine CA. Users may lose it, if they don't backup properly.

Following bash does the same:

#!/bin/bash
openssl s_client -showcerts -verify 5 -connect prod.de.tbs.toys:443 < /dev/null |
    awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{ if(/BEGIN CERTIFICATE/){a++}; out="cert"a".pem"; print >out}'
for cert in *.pem; do 
    newname=$(openssl x509 -noout -subject -in $cert | sed -nE 's/.*CN ?= ?(.*)/\1/; s/[ ,.*]/_/g; s/__/_/g; s/_-_/-/; s/^_//g;p' | tr '[:upper:]' '[:lower:]').pem
    if [[ "${newname}" == "boxine_ca.pem" ]]; then
        openssl x509 -in "${cert}" -out ca.der -outform DER
    fi
    rm ${cert}
done
@SciLor SciLor added the enhancement New feature or request label Dec 4, 2024
@marco79cgn
Copy link

marco79cgn commented Dec 6, 2024

Or as a one-liner:

echo "" | openssl s_client -host prod.de.tbs.toys -port 443 -showcerts | awk '/BEGIN CERTIFICATE/ {p=1} ; p==1; /END CERTIFICATE/ {p=0}' | awk '$0=="-----BEGIN CERTIFICATE-----" {n++} n>2' | openssl x509 -outform der -out ca.der

But saving the whole chain and looking for the CA name is probably safer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants