Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
certcheck
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
legi
soft
trokata
certcheck
Commits
1ba2910e
Commit
1ba2910e
authored
7 months ago
by
Gabriel Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Better code and better test ?
parent
61851285
No related branches found
No related tags found
No related merge requests found
Pipeline
#192651
passed
7 months ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
certcheck
+14
-24
14 additions, 24 deletions
certcheck
with
14 additions
and
24 deletions
certcheck
+
14
−
24
View file @
1ba2910e
...
...
@@ -5,7 +5,7 @@
export
PATH
=
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
export
LANG
=
C
export
VERSION
=
0.3.1
1
export
VERSION
=
0.3.1
2
function
usage
()
{
cat
<<
END_USAGE
...
...
@@ -30,17 +30,17 @@ function say_warning() {
[
-z
"
$(
pidof openssl
)
"
]
||
say_warning
"openssl running, consider: killall openssl"
PID_SSL
=
function
call_kick
()
{
function
call_
server_
kick
()
{
[
-n
"
${
PID_SSL
}
"
]
&&
kill
"
${
PID_SSL
}
"
&&
sleep
.2
PID_SSL
=
}
trap
'call_kick'
0
trap
'call_
server_
kick'
0
function
call_serve
()
{
call_kick
function
call_serve
r_launch
()
{
call_
server_
kick
PID_SSL
=
openssl s_server
-key
"
${
KEY
}
"
-cert
"
${
CRT
}
"
"
$@
"
-www
&
openssl s_server
-key
"
${
KEY
}
"
-cert
"
${
CRT
}
"
"
$@
"
-www
>
/dev/null
&
PID_SSL
=
$!
sleep
.5
# give it time to startup
}
...
...
@@ -62,17 +62,7 @@ function call_check_chained() {
}
function
call_check_selfsigned
()
{
while
read
-r
line
do
case
"
$line
"
in
'Verification error: self-signed certificate'
)
return
0
;;
'Verification error: '
*
)
return
1
;;
esac
done
< <
(
echo
| openssl s_client
-verify
8
-CApath
/etc/ssl/certs/
)
echo
| openssl s_client
-verify
8
-CApath
/etc/ssl/certs/ 2>&1 |
grep
-q
'Verification error: self-signed certificate'
&&
return
0
say_warning
"something failed, verification output not found!"
return
2
}
...
...
@@ -91,7 +81,7 @@ function check_certchained() {
return
$((${
same
}
-
1
))
}
function
call_cfiles
()
{
function
call_c
onfig
files
()
{
[
-s
"
${
CRT
}
"
]
||
CRT
=
"
${
ARG
}
"
[
-s
"
${
CRT
}
"
]
||
CRT
=
"
${
ARG
}
.cer"
[
-s
"
${
CRT
}
"
]
||
CRT
=
"
${
ARG
}
.pub.pem"
...
...
@@ -106,7 +96,7 @@ ARG="${1%.}"
CRT
=
"
${
ARG
}
.crt"
KEY
=
"
${
ARG
}
.key"
BND
=
"
${
ARG
}
.bundle"
call_cfiles
call_c
onfig
files
case
"
${
action
}
"
in
check
)
...
...
@@ -119,22 +109,22 @@ case "${action}" in
[
-s
"
${
BND
}
"
]
||
say_warning
"missing
${
BND
}
"
fi
call_serve
call_serve
r_launch
if
check_certchained
"
${
CRT
}
"
then
call_check_chained
&&
echo
"Error: CA-Bundle is not needed!"
echo
call_serve
-CAfile
"
${
BND
}
"
call_serve
r_launch
-CAfile
"
${
BND
}
"
call_check_chained
else
call_check_selfsigned
&&
echo
"Error: not self-signed certificate!"
call_check_selfsigned
||
echo
"Error: not self-signed certificate!"
echo
fi
ret
=
$?
call_kick
call_
server_
kick
echo
case
$ret
in
case
$
{
ret
}
in
0
)
echo
"Ok: everything is good"
echo
"ApacheConf: SSLCertificateKeyFile
${
KEY
}
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment