Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
added configuration to allow for pre-hashed key auth values.
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Lloyd <mike.lloyd@gsa.gov>
  • Loading branch information
siennathesane committed Nov 7, 2019
1 parent 3e9e64c commit 6ddc952
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type IntegrationServerOpts struct {
// verification.
AutoUpdateAuthZRecords bool

// Set to false if records being added to the server are already encrypted. Defaults to false.
AlreadyHashed bool

// The records handler so the DNS server can interact update records.
RecordHandler chan DnsMessage

Expand Down Expand Up @@ -80,6 +83,7 @@ func NewDefaultIntegrationServerOpts() *IntegrationServerOpts {
DnsPort: 5454,
Logger: logrus.New(),
Provider: NewDnsProvider(rh),
AlreadyHashed: false,
}
}

Expand Down Expand Up @@ -168,8 +172,13 @@ func (is *IntegrationServer) handleRecords() {
if is.Opts.AutoUpdateAuthZRecords {
is.mu.Lock()

keyAuthShaBytes := sha256.Sum256([]byte(msg.KeyAuth))
value := base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
var value string
if !is.Opts.AlreadyHashed {
keyAuthShaBytes := sha256.Sum256([]byte(msg.KeyAuth))
value = base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
} else {
value = msg.KeyAuth
}

is.TestRecords["_acme-challenge."+msg.Domain+"."] = value
is.mu.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func TestNewDefaultIntegrationServerOpts(t *testing.T) {
BaseDomain: "service",
DnsPort: 5454,
Logger: logrus.New(),
Provider: NewDnsProvider(trh),
Provider: NewDnsProvider(trh),
AlreadyHashed: false,
}

actual := NewDefaultIntegrationServerOpts()
Expand Down

0 comments on commit 6ddc952

Please sign in to comment.