Skip to content

Commit

Permalink
Avoid zeroing server.crt certificate (epoptes#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
eltoukos committed Jul 24, 2023
1 parent e428b34 commit 98ba08e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,9 @@ Implement Client.connect().
### 2023-07-21

Implement Client.info().

### 2023-07-24

Follow mentor advice to resolve existing upstream epoptes issues reported on
github, in place of the aforementioned blocked tasks. Resolve "server.crt is
blank" (#194).
12 changes: 7 additions & 5 deletions epoptes-client/epoptes-client
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ basic_info() {
}

fetch_certificate() {
local contents

test "$UID" -eq 0 || die "Need to be root to fetch the certificate"
mkdir -p /etc/epoptes
openssl s_client -connect $SERVER:$PORT </dev/null |
sed '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/!d' \
>/etc/epoptes/server.crt
if [ -s /etc/epoptes/server.crt ]; then
# First fetch, then store, to avoid zeroing the output file
if contents=$(openssl s_client -connect $SERVER:$PORT </dev/null |
sed '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/!d') &&
[ -n "$contents" ]; then
echo "$contents" >/etc/epoptes/server.crt
echo "Successfully fetched certificate from $SERVER:$PORT"
exit 0
else
die "Failed to fetch certificate from $SERVER:$PORT"
fi
Expand Down

0 comments on commit 98ba08e

Please sign in to comment.