AppendRootCAsToContext appends the given PEM encoded Root Certificates to the root CAs in the context.
(parent context.Context, pem []byte)
| 62 | |
| 63 | // AppendRootCAsToContext appends the given PEM encoded Root Certificates to the root CAs in the context. |
| 64 | func AppendRootCAsToContext(parent context.Context, pem []byte) context.Context { |
| 65 | certPool := RootCAsFromContext(parent) |
| 66 | if certPool != nil { |
| 67 | certPool = certPool.Clone() |
| 68 | } else { |
| 69 | certPool = x509.NewCertPool() |
| 70 | } |
| 71 | certPool.AppendCertsFromPEM(pem) |
| 72 | return context.WithValue(parent, rootCAsKey, certPool) |
| 73 | } |