()
| 315 | } |
| 316 | |
| 317 | func (g *Github) CACertBundle() ([]byte, error) { |
| 318 | if g.CACertBundlePath == "" { |
| 319 | // No CA bundle defined. |
| 320 | return nil, nil |
| 321 | } |
| 322 | if _, err := os.Stat(g.CACertBundlePath); err != nil { |
| 323 | return nil, fmt.Errorf("error accessing ca_cert_bundle: %w", err) |
| 324 | } |
| 325 | |
| 326 | contents, err := os.ReadFile(g.CACertBundlePath) |
| 327 | if err != nil { |
| 328 | return nil, fmt.Errorf("reading ca_cert_bundle: %w", err) |
| 329 | } |
| 330 | |
| 331 | roots := x509.NewCertPool() |
| 332 | if ok := roots.AppendCertsFromPEM(contents); !ok { |
| 333 | return nil, fmt.Errorf("failed to parse CA cert bundle") |
| 334 | } |
| 335 | |
| 336 | return contents, nil |
| 337 | } |
| 338 | |
| 339 | func (g *Github) UploadEndpoint() string { |
| 340 | if g.UploadBaseURL == "" { |
no outgoing calls