aboutsummaryrefslogtreecommitdiff
path: root/challange_http.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-23 17:05:03 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-23 17:05:03 +0100
commit650415dbf290bc8f4dc0d475da05e30619574153 (patch)
treece1ee6c05beb6487ec514735ee9059a029162510 /challange_http.go
parent6415a2c9bdf8fc1310268f705c9ef67f76e3416d (diff)
Add webroot solver
Diffstat (limited to 'challange_http.go')
-rw-r--r--challange_http.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/challange_http.go b/challange_http.go
index ee1708a..bd53ebf 100644
--- a/challange_http.go
+++ b/challange_http.go
@@ -2,8 +2,11 @@ package acme
import (
"io"
+ "io/ioutil"
"net"
"net/http"
+ "os"
+ "path"
)
const wellKnown = `/.well-known/acme-challenge/`
@@ -41,3 +44,16 @@ func (c httpChallenge) Solve() error {
<-done
return nil
}
+
+type webRoot struct {
+ Challenge
+ Webroot string
+}
+
+func (c webRoot) Solve() error {
+ file := path.Join(c.Webroot, wellKnown, c.Token)
+ if err := os.MkdirAll(path.Dir(file), 0755); err != nil {
+ return err
+ }
+ return ioutil.WriteFile(file, []byte(c.KeyAuthorization), 0644)
+}