Oregami
Repositories/oxedyne/fe2o3

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
3clear
4set -e # Exit immediately if a command exits with a non-zero status.
5
6user=$(whoami)
7home=/home/$user
8trg=$home/usr/code/web/apps/test/tls/
9mkdir -p $trg
10
11cert_file="$trg/fullchain.pem"
12key_file="$trg/privkey.pem"
13days_valid=365
14
15need_new_cert=false
16
17# Check if certificate files exist
18if [ ! -f "$cert_file" ] || [ ! -f "$key_file" ]; then
19 echo "Certificate or key file missing. Will create new ones."
20 need_new_cert=true
21else
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
34fi
35
36if $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"
40else
41 echo "Using existing TLS certificate"
42fi
43
44echo "Running integrated test..."
45cargo test integrated -- --nocapture