INNER CODE UNIT · Go

registerTLSConfig

qpoint-io/qtap · apps/mysql/go/main.go:108

func registerTLSConfig(caCertPath string) error {
	tlsConfig := &tls.Config{}

	if caCertPath != "" {
		rootCertPool := x509.NewCertPool()
		pem, err := os.ReadFile(caCertPath)
		if err != nil {
			return fmt.Errorf("failed to read CA cert: %w", err)
		}
		if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
			return fmt.Errorf("failed to append CA cert")
		}
		tlsConfig.RootCAs = rootCertPool
	}

	// Allow self-signed certs (for testing)
	if os.Getenv("MYSQL_TLS_SKIP_VERIFY") == "true" || caCertPath == "" {
		tlsConfig.InsecureSkipVerify = true

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…