Skip to content

Commit

Permalink
fix(bulk): fixing bulk loader when encryption + mtls is enabled (#7154)
Browse files Browse the repository at this point in the history
* fixing bulk loader when encryption + mtls is enabled

* making enterprise check early

* making tls var localised
  • Loading branch information
aman-bansal committed Dec 16, 2020
1 parent 0bebf74 commit a1eeaf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 0 additions & 13 deletions dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/worker"
"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
Expand Down Expand Up @@ -126,18 +125,6 @@ func (r *reducer) run() error {
}

func (r *reducer) createBadgerInternal(dir string, compression bool) *badger.DB {
if r.opt.EncryptionKey != nil {
// Need to set zero addr in WorkerConfig before checking the license.
x.WorkerConfig.ZeroAddr = []string{r.opt.ZeroAddr}

if !worker.EnterpriseEnabled() {
// Crash since the enterprise license is not enabled..
log.Fatal("Enterprise License needed for the Encryption feature.")
} else {
log.Printf("Encryption feature enabled.")
}
}

key := r.opt.EncryptionKey
if !r.opt.EncryptedOut {
key = nil
Expand Down
14 changes: 14 additions & 0 deletions dgraph/cmd/bulk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"strconv"
"strings"

"github.com/dgraph-io/dgraph/worker"

"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/tok"
"github.com/dgraph-io/dgraph/x"
Expand Down Expand Up @@ -187,6 +189,18 @@ func run() {
fmt.Fprint(os.Stderr, "Must set --encrypted and/or --encrypted_out to true when providing encryption key.\n")
os.Exit(1)
}

tlsConf, err := x.LoadClientTLSConfigForInternalPort(Bulk.Conf)
x.Check(err)
// Need to set zero addr in WorkerConfig before checking the license.
x.WorkerConfig.ZeroAddr = []string{opt.ZeroAddr}
x.WorkerConfig.TLSClientConfig = tlsConf
if !worker.EnterpriseEnabled() {
// Crash since the enterprise license is not enabled..
log.Fatal("Enterprise License needed for the Encryption feature.")
} else {
log.Printf("Encryption feature enabled.")
}
}
fmt.Printf("Encrypted input: %v; Encrypted output: %v\n", opt.Encrypted, opt.EncryptedOut)

Expand Down

0 comments on commit a1eeaf1

Please sign in to comment.