aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.go19
-rw-r--r--cmd/x/main.go20
-rw-r--r--messages.go4
3 files changed, 33 insertions, 10 deletions
diff --git a/client.go b/client.go
index d1705e7..a046f84 100644
--- a/client.go
+++ b/client.go
@@ -135,6 +135,21 @@ func (c *Client) Register(a *Account) error {
return err
}
-func (c *Client) Authorize(a *Account, d []string) error {
- return nil
+func (c *Client) Authorize(a *Account, domain string) error {
+ az := Authorization{
+ Resource: ResNewAuthz,
+ Identifier: Identifier{
+ Type: IdentDNS,
+ Value: domain,
+ },
+ }
+ resp, err := c.post(a, c.Dir.NewAuthz, az)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+ ae := AuthorizationResp{}
+ err = json.NewDecoder(resp.Body).Decode(&ae)
+ log.Println(ae)
+ return err
}
diff --git a/cmd/x/main.go b/cmd/x/main.go
index 6a7cae7..2ae8255 100644
--- a/cmd/x/main.go
+++ b/cmd/x/main.go
@@ -7,11 +7,6 @@ import (
)
func main() {
- c, err := acme.NewClient(acme.LES)
- if err != nil {
- log.Fatal(err)
- }
- log.Printf("%+v\n", c)
/*
a, err := acme.NewAccount("another@example.com", acme.KeySize)
@@ -26,7 +21,20 @@ func main() {
}
log.Printf("%+v\n", a)
- err = a.SaveAccount(".acme/account.json")
+ /*
+ err = a.SaveAccount(".acme/account.json")
+ if err != nil {
+ log.Fatal(err)
+ }
+ */
+
+ c, err := acme.NewClient(acme.LES)
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Printf("%+v\n", c)
+
+ err = c.Authorize(a, "example.com")
if err != nil {
log.Fatal(err)
}
diff --git a/messages.go b/messages.go
index c270f32..4ddaa42 100644
--- a/messages.go
+++ b/messages.go
@@ -64,8 +64,8 @@ type AuthorizationResp struct {
// Identifier ...
type Identifier struct {
- Type string `json:"type"` // dns
- Value string `json:"value"` // example.com
+ Type IdentType `json:"type"` // dns
+ Value string `json:"value"` // example.com
}
// Challege ...