(bundlePath string)
| 228 | } |
| 229 | |
| 230 | func parseAndReadCABundle(bundlePath string) ([]byte, error) { |
| 231 | if bundlePath == "" { |
| 232 | return nil, nil |
| 233 | } |
| 234 | |
| 235 | if _, err := os.Stat(bundlePath); os.IsNotExist(err) { |
| 236 | return nil, fmt.Errorf("CA cert file not found: %s", bundlePath) |
| 237 | } |
| 238 | contents, err := os.ReadFile(bundlePath) |
| 239 | if err != nil { |
| 240 | return nil, err |
| 241 | } |
| 242 | pemBlock, _ := pem.Decode(contents) |
| 243 | if pemBlock == nil { |
| 244 | return nil, fmt.Errorf("failed to decode PEM block") |
| 245 | } |
| 246 | if _, err := x509.ParseCertificates(pemBlock.Bytes); err != nil { |
| 247 | return nil, fmt.Errorf("failed to parse CA cert bundle: %w", err) |
| 248 | } |
| 249 | return contents, nil |
| 250 | } |
| 251 | |
| 252 | func parseCreateParams() (params.CreateGithubEndpointParams, error) { |
| 253 | certBundleBytes, err := parseAndReadCABundle(endpointCACertPath) |
no outgoing calls
no test coverage detected