SlashTLSConfig returns the TLS config appropriate for SlashGraphQL This assumes that endpoint is not empty, and in the format "domain.grpc.cloud.dg.io:443"
(endpoint string)
| 150 | // SlashTLSConfig returns the TLS config appropriate for SlashGraphQL |
| 151 | // This assumes that endpoint is not empty, and in the format "domain.grpc.cloud.dg.io:443" |
| 152 | func SlashTLSConfig(endpoint string) (*tls.Config, error) { |
| 153 | pool, err := generateCertPool("", true) |
| 154 | if err != nil { |
| 155 | return nil, err |
| 156 | } |
| 157 | hostWithoutPort := strings.Split(endpoint, ":")[0] |
| 158 | return &tls.Config{ |
| 159 | RootCAs: pool, |
| 160 | ServerName: hostWithoutPort, |
| 161 | MinVersion: tls.VersionTLS12, |
| 162 | }, nil |
| 163 | } |
| 164 | |
| 165 | // LoadClientTLSConfig loads the TLS config into the client with the given parameters. |
| 166 | func LoadClientTLSConfig(v *viper.Viper) (*tls.Config, error) { |
no test coverage detected