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
No related branches found
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'
...
@@ -11,6 +11,20 @@ alias subject_hash='openssl x509 -noout -subject_hash -in'
# Returns the issuer hash of the certificate path provided.
# Returns the issuer hash of the certificate path provided.
alias
issuer_hash
=
'openssl x509 -noout -issuer_hash -in'
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
()
{
find_root_cert
()
{
# Returns the (first) root (self-signed) certificate found in the list
# Returns the (first) root (self-signed) certificate found in the list
# of file paths provided.
# of file paths provided.
...
@@ -64,26 +78,21 @@ bundle_certs () {
...
@@ -64,26 +78,21 @@ bundle_certs () {
local
filename issuer issued bundle
local
filename issuer issued bundle
if
[
$#
-eq
0
]
if
[
$#
-eq
0
]
then
then
echo
"Usage: bundle_certs filename [filename2 [filename3 ...]]"
>>
/dev/stderr
__bc_usage
return
1
fi
fi
for
filename
in
"
$@
"
for
filename
in
"
$@
"
do
do
[
-f
"
$filename
"
]
&&
unbundle_cert
"
$filename
"
[
-f
"
$filename
"
]
&&
unbundle_cert
"
$filename
"
done
done
issuer
=
"
$(
find_root_cert certs/
*
)
"
issuer
=
"
$(
find_root_cert certs/
*
)
"
if
[
-z
"
$issuer
"
]
[
-z
"
$issuer
"
]
&&
__bc_die
"Failed to find root certificate."
then
bundle
=
"
$(
cat
"
$issuer
"
)
"
echo
"Failed to find root certificate."
>>
/dev/stderr
return
1
fi
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
bundle
=
"
$(
cat
"
$issued
"
)
"
while
[
-n
"
$issued
"
]
while
[
-n
"
$issued
"
]
do
do
bundle
=
"
$(
cat
"
$issued
"
;
echo
"
${
bundle
:-}
"
)
"
issuer
=
"
$issued
"
issuer
=
"
$issued
"
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
issued
=
"
$(
find_cert_by_issuer_hash
"
$(
basename
"
$issuer
"
)
"
certs/
*
)
"
[
-n
"
$issued
"
]
&&
bundle
=
"
$(
echo
"
${
bundle
:-}
"
;
cat
"
$issued
"
)
"
done
done
echo
"
$bundle
"
echo
"
$bundle
"
rm
-r
certs
rm
-r
certs
...
@@ -92,11 +101,6 @@ bundle_certs () {
...
@@ -92,11 +101,6 @@ bundle_certs () {
if
!
(
is_sourced
)
if
!
(
is_sourced
)
then
then
set
-eu
set
-eu
if
[
$#
-eq
0
]
[
$#
-eq
0
]
&&
__bc_usage
then
echo
"Usage:
$(
basename
"
$0
"
)
filename [filename2 [filename3 ...]]"
>>
/dev/stderr
return
1
else
bundle_certs
"
$@
"
bundle_certs
"
$@
"
fi
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