Skip to content

Commit

Permalink
multi: remove proof courier TLS certificate config file path
Browse files Browse the repository at this point in the history
Instead of specifying a TLS certificate file path, we now skip TLS
certificate verification whilst dialing into the proof courier service.
  • Loading branch information
ffranr committed Aug 30, 2023
1 parent 54dcc19 commit 9d2cd98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
9 changes: 2 additions & 7 deletions itest/aperture_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ type ApertureHarness struct {
// ListenAddr is the address that the aperture service is listening on.
ListenAddr string

// TlsCertPath is the path to the TLS certificate that the aperture
// service is using.
TlsCertPath string

// service is the instance of the aperture service that is running.
Service *aperture.Aperture
}
Expand Down Expand Up @@ -59,9 +55,8 @@ func NewApertureHarness(t *testing.T, port int) ApertureHarness {
service := aperture.NewAperture(cfg)

return ApertureHarness{
ListenAddr: listenAddr,
TlsCertPath: filepath.Join(baseDir, "tls.cert"),
Service: service,
ListenAddr: listenAddr,
Service: service,
}
}

Expand Down
1 change: 0 additions & 1 deletion itest/tapd_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func newTapdHarness(ht *harnessTest, cfg tapdConfig,
)

finalCfg.HashMailCourier = &proof.HashMailCourierCfg{
TlsCertPath: typedProofCourier.TlsCertPath,
ReceiverAckTimeout: receiverAckTimeout,
BackoffCfg: backoffCfg,
}
Expand Down
31 changes: 8 additions & 23 deletions proof/courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ func (h *HashMailCourierAddr) NewCourier(_ context.Context, cfg *CourierCfg,
recipient Recipient) (Courier, error) {

hashMailCfg := HashMailCourierCfg{
TlsCertPath: cfg.TlsCertPath,
ReceiverAckTimeout: cfg.ReceiverAckTimeout,
BackoffCfg: cfg.BackoffCfg,
}

hashMailBox, err := NewHashMailBox(&h.addr, hashMailCfg.TlsCertPath)
hashMailBox, err := NewHashMailBox(&h.addr)
if err != nil {
return nil, fmt.Errorf("unable to make mailbox: %v",
err)
Expand Down Expand Up @@ -230,25 +229,13 @@ type HashMailBox struct {

// serverDialOpts returns the set of server options needed to connect to the
// server using a TLS connection.
func serverDialOpts(tlsCertPath string) ([]grpc.DialOption, error) {
func serverDialOpts() ([]grpc.DialOption, error) {
var opts []grpc.DialOption

if tlsCertPath != "" {
// Read in the specified TLS certificate and build transport
// credentials with it.
creds, err := credentials.NewClientTLSFromFile(tlsCertPath, "")
if err != nil {
return nil, err
}
opts = append(opts, grpc.WithTransportCredentials(creds))

return opts, nil
}

// If TLS certificate file path not given, use the system's TLS trust
// store.
creds := credentials.NewTLS(&tls.Config{})
opts = append(opts, grpc.WithTransportCredentials(creds))
// Skip TLS certificate verification.
tlsConfig := tls.Config{InsecureSkipVerify: true}
transportCredentials := credentials.NewTLS(&tlsConfig)
opts = append(opts, grpc.WithTransportCredentials(transportCredentials))

return opts, nil
}
Expand All @@ -258,15 +245,15 @@ func serverDialOpts(tlsCertPath string) ([]grpc.DialOption, error) {
//
// NOTE: The TLS certificate path argument (tlsCertPath) is optional. If unset,
// then the system's TLS trust store is used.
func NewHashMailBox(courierAddr *url.URL, tlsCertPath string) (*HashMailBox,
func NewHashMailBox(courierAddr *url.URL) (*HashMailBox,
error) {

if courierAddr.Scheme != ApertureCourier {
return nil, fmt.Errorf("unsupported courier protocol: %v",
courierAddr.Scheme)
}

dialOpts, err := serverDialOpts(tlsCertPath)
dialOpts, err := serverDialOpts()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -467,8 +454,6 @@ type Recipient struct {

// HashMailCourierCfg is the config for the hashmail proof courier.
type HashMailCourierCfg struct {
TlsCertPath string `long:"tlscertpath" description:"Service TLS certificate file path"`

// ReceiverAckTimeout is the maximum time we'll wait for the receiver to
// acknowledge the proof.
ReceiverAckTimeout time.Duration `long:"receiveracktimeout" description:"The maximum time to wait for the receiver to acknowledge the proof."`
Expand Down
1 change: 0 additions & 1 deletion tapcfg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
// support a proof courier.
if cfg.HashMailCourier != nil {
proofCourierCfg = &proof.CourierCfg{
TlsCertPath: cfg.HashMailCourier.TlsCertPath,
ReceiverAckTimeout: cfg.HashMailCourier.ReceiverAckTimeout,
BackoffCfg: cfg.HashMailCourier.BackoffCfg,
DeliveryLog: assetStore,
Expand Down

0 comments on commit 9d2cd98

Please sign in to comment.