LoadServerTLSConfig loads the TLS config into the server with the given parameters.
(v *viper.Viper)
| 131 | |
| 132 | // LoadServerTLSConfig loads the TLS config into the server with the given parameters. |
| 133 | func LoadServerTLSConfig(v *viper.Viper) (*tls.Config, error) { |
| 134 | tlsFlag := z.NewSuperFlag(v.GetString("tls")).MergeAndCheckDefault(TLSDefaults) |
| 135 | |
| 136 | if tlsFlag.GetPath("server-cert") == "" && tlsFlag.GetPath("server-key") == "" { |
| 137 | return nil, nil |
| 138 | } |
| 139 | |
| 140 | conf := TLSHelperConfig{} |
| 141 | conf.RootCACert = tlsFlag.GetPath("ca-cert") |
| 142 | conf.CertRequired = true |
| 143 | conf.Cert = tlsFlag.GetPath("server-cert") |
| 144 | conf.Key = tlsFlag.GetPath("server-key") |
| 145 | conf.ClientAuth = tlsFlag.GetString("client-auth-type") |
| 146 | conf.UseSystemCACerts = tlsFlag.GetBool("use-system-ca") |
| 147 | return GenerateServerTLSConfig(&conf) |
| 148 | } |
| 149 | |
| 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" |
no test coverage detected