Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
a16beb98
Commit
a16beb98
authored
Oct 21, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
letsencrypt: Revoke certificate
parent
c626774d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
config/letsencrypt/letsencrypt.go
config/letsencrypt/letsencrypt.go
+35
-6
main.go
main.go
+10
-0
No files found.
config/letsencrypt/letsencrypt.go
View file @
a16beb98
...
...
@@ -419,6 +419,41 @@ func getNextRenewalShedule() (int, error) {
return
hoursSinceRenew
,
nil
}
// Revoke revokes the certificate for host via ACME protocol.
func
Revoke
(
host
string
)
error
{
if
!
existingCertAndKey
(
host
)
{
return
errors
.
New
(
"no certificate and key for "
+
host
)
}
email
:=
getEmail
(
server
.
Config
{
Host
:
host
})
if
email
==
""
{
return
errors
.
New
(
"email is required to revoke"
)
}
client
,
err
:=
newClient
(
email
)
if
err
!=
nil
{
return
err
}
certFile
:=
storage
.
SiteCertFile
(
host
)
certBytes
,
err
:=
ioutil
.
ReadFile
(
certFile
)
if
err
!=
nil
{
return
err
}
err
=
client
.
RevokeCertificate
(
certBytes
)
if
err
!=
nil
{
return
err
}
err
=
os
.
Remove
(
certFile
)
if
err
!=
nil
{
return
errors
.
New
(
"certificate revoked, but unable to delete certificate file: "
+
err
.
Error
())
}
return
nil
}
var
(
// Let's Encrypt account email to use if none provided
DefaultEmail
string
...
...
@@ -455,9 +490,3 @@ const (
// This shouldn't need to change except for in tests;
// the size can be drastically reduced for speed.
var
rsaKeySizeToUse
=
RSA_2048
// CertificateMeta is a container type used to write out a file
// with information about a certificate.
type
CertificateMeta
struct
{
Domain
,
URL
string
}
main.go
View file @
a16beb98
...
...
@@ -23,6 +23,7 @@ var (
conf
string
cpu
string
version
bool
revoke
string
)
func
init
()
{
...
...
@@ -36,6 +37,7 @@ func init() {
flag
.
BoolVar
(
&
version
,
"version"
,
false
,
"Show version"
)
flag
.
BoolVar
(
&
letsencrypt
.
Agreed
,
"agree"
,
false
,
"Agree to Let's Encrypt Subscriber Agreement"
)
flag
.
StringVar
(
&
letsencrypt
.
DefaultEmail
,
"email"
,
""
,
"Default email address to use for Let's Encrypt transactions"
)
flag
.
StringVar
(
&
revoke
,
"revoke"
,
""
,
"Hostname for which to revoke the certificate"
)
}
func
main
()
{
...
...
@@ -45,6 +47,14 @@ func main() {
fmt
.
Printf
(
"%s %s
\n
"
,
app
.
Name
,
app
.
Version
)
os
.
Exit
(
0
)
}
if
revoke
!=
""
{
err
:=
letsencrypt
.
Revoke
(
revoke
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
fmt
.
Printf
(
"Revoked certificate for %s
\n
"
,
revoke
)
os
.
Exit
(
0
)
}
// Set CPU cap
err
:=
app
.
SetCPU
(
cpu
)
...
...
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