Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bundle_certs
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
nimrod
bundle_certs
Commits
7c7e351b
Commit
7c7e351b
authored
7 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
- Added "namespaced" die and usage functions.
- Fix for bundle creation.
parent
af02608f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bundle_certs
+20
-16
20 additions, 16 deletions
bundle_certs
with
20 additions
and
16 deletions
bundle_certs
+
20
−
16
View file @
7c7e351b
...
...
@@ -11,6 +11,20 @@ alias subject_hash='openssl x509 -noout -subject_hash -in'
# Returns the issuer hash of the certificate path provided.
alias
issuer_hash
=
'openssl x509 -noout -issuer_hash -in'
__bc_die
()
{
echo
"
$@
"
>>
/dev/stderr
return
1
}
__bc_usage
()
{
if
(
is_sourced
)
then
__bc_die
"Usage: bundle_certs filename [filename2 [filename3 ...]]"
else
__bc_die
"Usage:
$(
basename
"
$0
"
)
filename [filename2 [filename3 ...]]"
fi
}
find_root_cert
()
{
# Returns the (first) root (self-signed) certificate found in the list
# of file paths provided.
...
...
@@ -64,26 +78,21 @@ bundle_certs () {
local
filename issuer issued bundle
if
[
$#
-eq
0
]
then
echo
"Usage: bundle_certs filename [filename2 [filename3 ...]]"
>>
/dev/stderr
return
1
__bc_usage
fi
for
filename
in
"
$@
"
do
[
-f
"
$filename
"
]
&&
unbundle_cert
"
$filename
"
done
issuer
=
"
$(
find_root_cert certs/
*
)
"
if
[
-z
"
$issuer
"
]
then
echo
"Failed to find root certificate."
>>
/dev/stderr
return
1
fi
[
-z
"
$issuer
"
]
&&
__bc_die
"Failed to find root certificate."
bundle
=
"
$(
cat
"
$issuer
"
)
"
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
bundle
=
"
$(
cat
"
$issued
"
)
"
while
[
-n
"
$issued
"
]
do
bundle
=
"
$(
cat
"
$issued
"
;
echo
"
${
bundle
:-}
"
)
"
issuer
=
"
$issued
"
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
[
-n
"
$issued
"
]
&&
bundle
=
"
$(
echo
"
${
bundle
:-}
"
;
cat
"
$issued
"
)
"
done
echo
"
$bundle
"
rm
-r
certs
...
...
@@ -92,11 +101,6 @@ bundle_certs () {
if
!
(
is_sourced
)
then
set
-eu
if
[
$#
-eq
0
]
then
echo
"Usage:
$(
basename
"
$0
"
)
filename [filename2 [filename3 ...]]"
>>
/dev/stderr
return
1
else
[
$#
-eq
0
]
&&
__bc_usage
bundle_certs
"
$@
"
fi
fi
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