feat: add certs path and mtls setup for shamir coordinator client (#414)

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2024-06-27 10:09:34 +02:00 committed by GitHub
parent 7d87d662ea
commit a4c8c821d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -5,11 +5,13 @@ import (
"context"
"encoding/json"
"io"
"log"
"net/http"
"net/url"
"strings"
"github.com/planetmint/planetmint-go/config"
"github.com/rddl-network/go-utils/tls"
)
// TODO: revert to actual rddl-claim-service client after CosmosSDK upgrade to v0.50.x
@ -22,7 +24,11 @@ func lazyLoadShamirCoordinatorClient() IShamirCoordinatorClient {
return ShamirCoordinatorServiceClient
}
cfg := config.GetConfig()
ShamirCoordinatorServiceClient = NewShamirCoordinatorClient(cfg.IssuerHost, &http.Client{})
httpsClient, err := tls.Get2WayTLSClient(cfg.CertsPath)
if err != nil {
defer log.Fatal("fatal error setting up mutual tls client for shamir coordinator")
}
ShamirCoordinatorServiceClient = NewShamirCoordinatorClient(cfg.IssuerHost, httpsClient)
return ShamirCoordinatorServiceClient
}

View File

@ -26,6 +26,7 @@ mqtt-password = "{{ .PlmntConfig.MqttPassword }}"
claim-host = "{{ .PlmntConfig.ClaimHost }}"
mqtt-tls = {{ .PlmntConfig.MqttTLS }}
issuer-host = "{{ .PlmntConfig.IssuerHost }}"
certs-path = "{{ .PlmntConfig.CertsPath }}"
`
// Config defines Planetmint's top level configuration
@ -45,6 +46,7 @@ type Config struct {
ClaimHost string `json:"claim-host" mapstructure:"claim-host"`
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
IssuerHost string `json:"issuer-host" mapstructure:"issuer-host"`
CertsPath string `json:"certs-path" mapstructure:"certs-path"`
}
// cosmos-sdk wide global singleton
@ -71,6 +73,7 @@ func DefaultConfig() *Config {
ClaimHost: "https://testnet-p2r.rddl.io",
MqttTLS: true,
IssuerHost: "https://testnet-issuer.rddl.io",
CertsPath: "./certs/",
}
}