mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
parent
6088d45686
commit
ad4da5f043
@ -42,15 +42,18 @@ flag=$base_dir/cert_gen_type
|
|||||||
#The location of harbor.cfg
|
#The location of harbor.cfg
|
||||||
cfg=$base_dir/harbor/harbor.cfg
|
cfg=$base_dir/harbor/harbor.cfg
|
||||||
|
|
||||||
#Format cert and key files
|
#Format cert file
|
||||||
function format {
|
function formatCert {
|
||||||
file=$1
|
content=$1
|
||||||
head=$(sed -rn 's/(-+[A-Za-z ]*-+)([^-]*)(-+[A-Za-z ]*-+)/\1/p' $file)
|
file=$2
|
||||||
body=$(sed -rn 's/(-+[A-Za-z ]*-+)([^-]*)(-+[A-Za-z ]*-+)/\2/p' $file)
|
echo $content | sed -r "s/ /\n/g" | sed -r "/-+$/d" | sed -r "s/^(-+).*/& CERTIFICATE\1/g" > $file
|
||||||
tail=$(sed -rn 's/(-+[A-Za-z ]*-+)([^-]*)(-+[A-Za-z ]*-+)/\3/p' $file)
|
}
|
||||||
echo $head > $file
|
|
||||||
echo $body | sed 's/\s\+/\n/g' >> $file
|
#Format key file
|
||||||
echo $tail >> $file
|
function formatKey {
|
||||||
|
content=$1
|
||||||
|
file=$2
|
||||||
|
echo $content | sed -r "s/ /\n/g" | sed -r "/^PRIVATE$/d"| sed -r "/-+$/d" | sed -r "s/^(-+).*/& PRIVATE KEY\1/g" > $file
|
||||||
}
|
}
|
||||||
|
|
||||||
function genCert {
|
function genCert {
|
||||||
@ -81,10 +84,8 @@ function secure {
|
|||||||
if [ -n "$ssl_cert" ] && [ -n "$ssl_cert_key" ]
|
if [ -n "$ssl_cert" ] && [ -n "$ssl_cert_key" ]
|
||||||
then
|
then
|
||||||
echo "ssl_cert and ssl_cert_key are both set, using customized certificate"
|
echo "ssl_cert and ssl_cert_key are both set, using customized certificate"
|
||||||
echo $ssl_cert > $cert
|
formatCert "$ssl_cert" $cert
|
||||||
format $cert
|
formatKey "$ssl_cert_key" $key
|
||||||
echo $ssl_cert_key > $key
|
|
||||||
format $key
|
|
||||||
echo "customized" > $flag
|
echo "customized" > $flag
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user