-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.5 service probe, version upgrade, and misc fixes
- Loading branch information
Showing
52 changed files
with
1,989 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"crypto/tls" | ||
"encoding/base64" | ||
"time" | ||
|
||
"github.com/anchordotdev/cli" | ||
"golang.org/x/crypto/acme" | ||
"golang.org/x/crypto/acme/autocert" | ||
) | ||
|
||
func ProvisionCert(eab *Eab, domains []string, acmeURL string) (*tls.Certificate, error) { | ||
hmacKey, err := base64.URLEncoding.DecodeString(eab.HmacKey) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
mgr := &autocert.Manager{ | ||
Prompt: autocert.AcceptTOS, | ||
HostPolicy: autocert.HostWhitelist(domains...), | ||
Client: &acme.Client{ | ||
DirectoryURL: acmeURL, | ||
UserAgent: cli.UserAgent(), | ||
}, | ||
ExternalAccountBinding: &acme.ExternalAccountBinding{ | ||
KID: eab.Kid, | ||
Key: hmacKey, | ||
}, | ||
RenewBefore: 24 * time.Hour, | ||
} | ||
|
||
// TODO: switch to using ACME package here, so that extra domains can be sent through for SAN extension | ||
clientHello := &tls.ClientHelloInfo{ | ||
ServerName: domains[0], | ||
CipherSuites: []uint16{tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, | ||
} | ||
|
||
return mgr.GetCertificate(clientHello) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.