fix cerrificate bundle issue. (#1266)

LGTM
This commit is contained in:
Wenkai Yin 2016-12-26 15:49:53 +08:00 committed by yhua123
parent 6088d45686
commit ad4da5f043

View File

@ -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