Debian Codegraph @

internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl

raw
1 // Code generated by gotmpl. DO NOT MODIFY.
2 // source: internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl
3
4 // Copyright The OpenTelemetry Authors
5 // SPDX-License-Identifier: Apache-2.0
6
7 package otlpconfig
8
9 import (
10 "crypto/tls"
11 "crypto/x509"
12 "errors"
13 )
14
15 // CreateTLSConfig creates a tls.Config from a raw certificate bytes
16 // to verify a server certificate.
17 func CreateTLSConfig(certBytes []byte) (*tls.Config, error) {
18 cp := x509.NewCertPool()
19 if ok := cp.AppendCertsFromPEM(certBytes); !ok {
20 return nil, errors.New("failed to append certificate to the cert pool")
21 }
22
23 return &tls.Config{
24 RootCAs: cp,
25 }, nil
26 }