blob: dc3c8789bcb2ef562981cfcc389e09672c0b4533 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package acme
import (
"io"
"log"
"os"
"path"
)
type webrootSolver struct {
webroot string
file string
}
func NewWebrootSolver(webroot string) Solver {
return &webrootSolver{webroot: webroot}
}
func (s *webrootSolver) Solve(ch Challenge) error {
s.file = path.Join(s.webroot, WellKnown, ch.Token)
log.Println("solve webroot", s.file)
fd, err := CreatePubFile(s.file)
if err != nil {
return err
}
defer fd.Close()
_, err = io.WriteString(fd, ch.KeyAuthorization)
return err
}
func (s *webrootSolver) Solved() error {
return os.Remove(s.file)
}
func (webrootSolver) Type() ChalType { return ChallengeHTTP }
|