examples/tls/index.js
function newClientStub() {
    // First create the appropriate TLS certs with dgraph cert:
    //     $ dgraph cert
    //     $ dgraph cert -n localhost
    //     $ dgraph cert -c user
    const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
    const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
    const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
    return new dgraph.DgraphClientStub(
        "localhost:9080",
        grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
function newClientStub() {
    // First create the appropriate TLS certs with dgraph cert:
    //     $ dgraph cert
    //     $ dgraph cert -n localhost
    //     $ dgraph cert -c user
    const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
    const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
    const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
    return new dgraph.DgraphClientStub(
        "localhost:9080",
        grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
function newClientStub ( ) { // First create the appropriate TLS certs with dgraph cert: //     $ dgraph cert //     $ dgraph cert -n localhost //     $ dgraph cert -c user const rootCaCert = fs . readFileSync ( path . join ( __dirname , 'tls' , 'ca.crt' ) ) ; const clientCertKey = fs . readFileSync ( path . join ( __dirname , 'tls' , 'client.user.key' ) ) ; const clientCert = fs . readFileSync ( path . join ( __dirname , 'tls' , 'client.user.crt' ) ) ; return new dgraph . DgraphClientStub ( "localhost:9080" , grpc . credentials . createSsl ( rootCaCert , clientCertKey , clientCert ) ) ; }
Create a client stub.
Create a client stub .