Skip to content

Commit

Permalink
Verify IP identifier contains valid IP
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Jun 3, 2021
1 parent 6486e60 commit a0e92f8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions acme/api/order.go
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/x509"
"encoding/base64"
"encoding/json"
"net"
"net/http"
"strings"
"time"
Expand All @@ -31,6 +32,9 @@ func (n *NewOrderRequest) Validate() error {
if !(id.Type == "dns" || id.Type == "ip") {
return acme.NewError(acme.ErrorMalformedType, "identifier type unsupported: %s", id.Type)
}
if id.Type == "ip" && net.ParseIP(id.Value) == nil {
return acme.NewError(acme.ErrorMalformedType, "%s is not a valid IP address", id.Value)
}
}
return nil
}
Expand Down Expand Up @@ -85,6 +89,7 @@ func (h *Handler) NewOrder(w http.ResponseWriter, r *http.Request) {
"failed to unmarshal new-order request payload"))
return
}

if err := nor.Validate(); err != nil {
api.WriteError(w, err)
return
Expand Down

0 comments on commit a0e92f8

Please sign in to comment.