aboutsummaryrefslogtreecommitdiff
path: root/challenge.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-07 14:36:50 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-07 14:36:50 +0100
commit98b7cd41de84742c6c4b895d42a1203f02a442a4 (patch)
treef8f54cc1b9848db5e124e76dae2402cf85a612f4 /challenge.go
parent2d5b6fc0ca29c3821fc47d48005f7eb9e6769b56 (diff)
Move SNIName to Challenge
Diffstat (limited to 'challenge.go')
-rw-r--r--challenge.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/challenge.go b/challenge.go
index e7b28c2..abc35ef 100644
--- a/challenge.go
+++ b/challenge.go
@@ -1,6 +1,10 @@
package acme
-import "time"
+import (
+ "crypto/sha256"
+ "encoding/hex"
+ "time"
+)
// Challege ...
type Challenge struct {
@@ -14,6 +18,15 @@ type Challenge struct {
Err *Problem `json:"error,omitempty"`
}
+const AcmeInvalid = `.acme.invalid`
+
+// SNIName returns a new SNI name based on KeyAuthorization
+func (c Challenge) SNIName() string {
+ hash := sha256.Sum256([]byte(c.KeyAuthorization))
+ z := hex.EncodeToString(hash[:])
+ return z[:32] + "." + z[32:] + AcmeInvalid
+}
+
// Status of request
type Status string