Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
960ab88c
Commit
960ab88c
authored
Jan 06, 2016
by
neil
Browse files
minor, fix error messages
parent
bf108bb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
le.sh
View file @
960ab88c
...
@@ -47,15 +47,13 @@ createAccountKey() {
...
@@ -47,15 +47,13 @@ createAccountKey() {
account
=
$1
account
=
$1
length
=
$2
length
=
$2
if
[
-z
"
$2
"
]
;
then
if
[
-z
"
$2
"
]
;
then
ech
o
Use default length 2048
_inf
o
"
Use default length 2048
"
length
=
2048
length
=
2048
fi
fi
_initpath
_initpath
mkdir
-p
$WORKING_DIR
ACCOUNT_KEY_PATH
=
$WORKING_DIR
/account.acc
if
[
-f
"
$ACCOUNT_KEY_PATH
"
]
;
then
if
[
-f
"
$ACCOUNT_KEY_PATH
"
]
;
then
echo
a
ccount key exists, skip
_info
"A
ccount key exists, skip
"
return
return
else
else
#generate account key
#generate account key
...
@@ -74,7 +72,7 @@ createDomainKey() {
...
@@ -74,7 +72,7 @@ createDomainKey() {
domain
=
$1
domain
=
$1
length
=
$2
length
=
$2
if
[
-z
"
$2
"
]
;
then
if
[
-z
"
$2
"
]
;
then
ech
o
Use default length 2048
_inf
o
"
Use default length 2048
"
length
=
2048
length
=
2048
fi
fi
_initpath
$domain
_initpath
$domain
...
@@ -82,7 +80,7 @@ createDomainKey() {
...
@@ -82,7 +80,7 @@ createDomainKey() {
CERT_KEY_PATH
=
$WORKING_DIR
/
$domain
/
$domain
.key
CERT_KEY_PATH
=
$WORKING_DIR
/
$domain
/
$domain
.key
if
[
-f
"
$CERT_KEY_PATH
"
]
;
then
if
[
-f
"
$CERT_KEY_PATH
"
]
;
then
echo
d
omain key exists, skip
_info
"D
omain key exists, skip
"
else
else
#generate account key
#generate account key
openssl genrsa
$length
>
$CERT_KEY_PATH
openssl genrsa
$length
>
$CERT_KEY_PATH
...
@@ -102,18 +100,18 @@ createCSR() {
...
@@ -102,18 +100,18 @@ createCSR() {
domainlist
=
$2
domainlist
=
$2
if
[
-f
$CSR_PATH
]
;
then
if
[
-f
$CSR_PATH
]
;
then
ech
o
CSR exists, skip
_inf
o
"
CSR exists, skip
"
return
return
fi
fi
if
[
-z
"
$domainlist
"
]
;
then
if
[
-z
"
$domainlist
"
]
;
then
#single domain
#single domain
echo
s
ingle domain
_info
"S
ingle domain
"
$domain
openssl req
-new
-sha256
-key
$CERT_KEY_PATH
-subj
"/CN=
$domain
"
>
$CSR_PATH
openssl req
-new
-sha256
-key
$CERT_KEY_PATH
-subj
"/CN=
$domain
"
>
$CSR_PATH
else
else
alt
=
DNS:
$(
echo
$domainlist
|
sed
"s/,/,DNS:/g"
)
alt
=
DNS:
$(
echo
$domainlist
|
sed
"s/,/,DNS:/g"
)
#multi
#multi
echo
m
ulti domain
$alt
_info
"M
ulti domain
"
$alt
openssl req
-new
-sha256
-key
$CERT_KEY_PATH
-subj
"/CN=
$domain
"
-reqexts
SAN
-config
<
(
printf
"[ req_distinguished_name ]
\n
[ req ]
\n
distinguished_name = req_distinguished_name
\n
[SAN]
\n
subjectAltName=
$alt
"
)
-out
$CSR_PATH
openssl req
-new
-sha256
-key
$CERT_KEY_PATH
-subj
"/CN=
$domain
"
-reqexts
SAN
-config
<
(
printf
"[ req_distinguished_name ]
\n
[ req ]
\n
distinguished_name = req_distinguished_name
\n
[SAN]
\n
subjectAltName=
$alt
"
)
-out
$CSR_PATH
fi
fi
...
@@ -222,7 +220,7 @@ _startserver() {
...
@@ -222,7 +220,7 @@ _startserver() {
_stopserver
()
{
_stopserver
()
{
pid
=
"
$1
"
pid
=
"
$1
"
if
[
"
$pid
"
]
;
then
if
[
"
$pid
"
]
;
then
if
[
-z
"
$DEBUG
"
]
;
then
if
[
"
$DEBUG
"
]
;
then
kill
-s
9
$pid
2>&1
kill
-s
9
$pid
2>&1
killall
-s
9 nc 2>&1
killall
-s
9 nc 2>&1
else
else
...
@@ -375,7 +373,7 @@ issue() {
...
@@ -375,7 +373,7 @@ issue() {
alldomains
=
$(
echo
"
$Le_Domain
,
$Le_Alt
"
|
sed
"s/,/ /g"
)
alldomains
=
$(
echo
"
$Le_Domain
,
$Le_Alt
"
|
sed
"s/,/ /g"
)
for
d
in
$alldomains
for
d
in
$alldomains
do
do
_info
"Verifing domain
$d
"
_info
"Verifing domain
"
$d
_send_signed_request
"
$API
/acme/new-authz"
"{
\"
resource
\"
:
\"
new-authz
\"
,
\"
identifier
\"
: {
\"
type
\"
:
\"
dns
\"
,
\"
value
\"
:
\"
$d
\"
}}"
_send_signed_request
"
$API
/acme/new-authz"
"{
\"
resource
\"
:
\"
new-authz
\"
,
\"
identifier
\"
: {
\"
type
\"
:
\"
dns
\"
,
\"
value
\"
:
\"
$d
\"
}}"
...
@@ -398,7 +396,7 @@ issue() {
...
@@ -398,7 +396,7 @@ issue() {
if
[
"
$Le_Webroot
"
==
"no"
]
;
then
if
[
"
$Le_Webroot
"
==
"no"
]
;
then
_info
"Standalone mode server"
_info
"Standalone mode server"
_startserver
"
$keyauthorization
"
&
2>&1
>
/dev/null
_startserver
"
$keyauthorization
"
2>&1
>
/dev/null
&
serverproc
=
"
$!
"
serverproc
=
"
$!
"
sleep
2
sleep
2
_debug serverproc
$serverproc
_debug serverproc
$serverproc
...
@@ -435,7 +433,7 @@ issue() {
...
@@ -435,7 +433,7 @@ issue() {
status
=
$(
echo
$response
| egrep
-o
'"status":"[^"]+"'
|
cut
-d
:
-f
2 |
sed
's/"//g'
)
status
=
$(
echo
$response
| egrep
-o
'"status":"[^"]+"'
|
cut
-d
:
-f
2 |
sed
's/"//g'
)
if
[
"
$status
"
==
"valid"
]
;
then
if
[
"
$status
"
==
"valid"
]
;
then
_info
"
Verify s
uccess
:
$d
"
_info
"
S
uccess"
break
;
break
;
fi
fi
...
@@ -447,7 +445,7 @@ issue() {
...
@@ -447,7 +445,7 @@ issue() {
fi
fi
if
[
"
$status
"
==
"pending"
]
;
then
if
[
"
$status
"
==
"pending"
]
;
then
_info
"
Verify p
ending
:
$d
"
_info
"
P
ending"
else
else
_err
"Verify error:
$response
"
_err
"Verify error:
$response
"
_stopserver
$serverproc
_stopserver
$serverproc
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment