ParseCertificates parses the hardcoded Azure intermediate certificates and returns them as x509.Certificate values.
()
| 322 | // ParseCertificates parses the hardcoded Azure intermediate |
| 323 | // certificates and returns them as x509.Certificate values. |
| 324 | func ParseCertificates() ([]*x509.Certificate, error) { |
| 325 | var certs []*x509.Certificate |
| 326 | for _, certPEM := range Certificates { |
| 327 | block, rest := pem.Decode([]byte(certPEM)) |
| 328 | if len(rest) != 0 { |
| 329 | return nil, xerrors.Errorf("invalid certificate. %d bytes remain", len(rest)) |
| 330 | } |
| 331 | cert, err := x509.ParseCertificate(block.Bytes) |
| 332 | if err != nil { |
| 333 | return nil, xerrors.Errorf("parse certificate: %w", err) |
| 334 | } |
| 335 | certs = append(certs, cert) |
| 336 | } |
| 337 | return certs, nil |
| 338 | } |
| 339 | |
| 340 | // Certificates are manually downloaded from Azure, then processed with OpenSSL |
| 341 | // and added here. See: https://learn.microsoft.com/en-us/azure/security/fundamentals/azure-ca-details |