-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcert.sh
More file actions
executable file
·39 lines (31 loc) · 957 Bytes
/
Copy pathcert.sh
File metadata and controls
executable file
·39 lines (31 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
set -euo pipefail
# Certificate management functions
# Handles validation of SSL certificate files
# Validate that certificate files exist and are not empty
# Args:
# $1: Directory containing cert.pem and key.pem
# Returns:
# 0 if valid, 1 if invalid
cert_validate_files() {
local cert_dir="$1"
if [[ ! -f "$cert_dir/cert.pem" ]]; then
echo "Error: Certificate file not found: $cert_dir/cert.pem" >&2
return 1
fi
if [[ ! -f "$cert_dir/key.pem" ]]; then
echo "Error: Private key file not found: $cert_dir/key.pem" >&2
return 1
fi
if [[ ! -s "$cert_dir/cert.pem" ]]; then
echo "Error: Certificate file is empty: $cert_dir/cert.pem" >&2
return 1
fi
if [[ ! -s "$cert_dir/key.pem" ]]; then
echo "Error: Private key file is empty: $cert_dir/key.pem" >&2
return 1
fi
return 0
}
# Export functions
export -f cert_validate_files