go-grpc-optionaltls-creds

module
v0.0.0-...-81c4703 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2021 License: MIT

README

Tests

go-grpc-optionaltls-creds

The Go language implementation of gRPC TransportCredentials that supports optional TLS connections.

Simple example

optionaltls.New wraps provided TransportCredentials. It uses provided credentials if a client connected with TLS and bypasses if connection is plain-text

import (
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials"

    "github.com/noxiouz/go-grpc-optionaltls-creds/optionaltls"
)

// Control in runtime. See docs
var dynamicOptionF = optionaltls.DynamicOption(func() bool {
    return true
})

func createServer(credentials credentials.TransportCredentials) *grpc.Server {
    serverCredentials = optionaltls.New(credentials) // optionaltls.NewWithDynamicOption(credentials, dynamicOptionF))
    s := grpc.NewServer(grpc.Creds(serverCredentials))
    return s
}

Implementation

Detection mechanism is inspired by fbthrift and The Illustrated TLS Connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL