oxedyne/fe2o3/fe2o3_steel/test
1.2 KiB, 1 run, executable
created by r1870400018:1003, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | #!/bin/bash |
| 2 | |
| 3 | clear |
| 4 | set -e # Exit immediately if a command exits with a non-zero status. |
| 5 | |
| 6 | user=$(whoami) |
| 7 | home=/home/$user |
| 8 | trg=$home/usr/code/web/apps/test/tls/ |
| 9 | mkdir -p $trg |
| 10 | |
| 11 | cert_file="$trg/fullchain.pem" |
| 12 | key_file="$trg/privkey.pem" |
| 13 | days_valid=365 |
| 14 | |
| 15 | need_new_cert=false |
| 16 | |
| 17 | # Check if certificate files exist |
| 18 | if [ ! -f "$cert_file" ] || [ ! -f "$key_file" ]; then |
| 19 | echo "Certificate or key file missing. Will create new ones." |
| 20 | need_new_cert=true |
| 21 | else |
| 22 | # Check certificate expiration |
| 23 | exp_date=$(openssl x509 -enddate -noout -in "$cert_file" | cut -d= -f2) |
| 24 | exp_epoch=$(date -d "$exp_date" +%s) |
| 25 | now_epoch=$(date +%s) |
| 26 | days_left=$(( ($exp_epoch - $now_epoch) / 86400 )) |
| 27 | |
| 28 | if [ $days_left -lt 30 ]; then |
| 29 | echo "Certificate will expire in $days_left days. Will create new one." |
| 30 | need_new_cert=true |
| 31 | else |
| 32 | echo "Certificate is valid for $days_left more days." |
| 33 | fi |
| 34 | fi |
| 35 | |
| 36 | if $need_new_cert; then |
| 37 | openssl req -x509 -newkey rsa:4096 -keyout "$key_file" -out "$cert_file" \ |
| 38 | -days $days_valid -nodes -config tests/openssl.cnf |
| 39 | echo "Created new TLS certificate" |
| 40 | else |
| 41 | echo "Using existing TLS certificate" |
| 42 | fi |
| 43 | |
| 44 | echo "Running integrated test..." |
| 45 | cargo test integrated -- --nocapture |