(path string, certBytes []byte)
| 164 | } |
| 165 | |
| 166 | func writeCertificate(path string, certBytes []byte) error { |
| 167 | file, err := os.Create(path) |
| 168 | if err != nil { |
| 169 | return fmt.Errorf("writeCertificate: %w", err) |
| 170 | } |
| 171 | |
| 172 | err = pem.Encode(file, &pem.Block{ |
| 173 | Type: "CERTIFICATE", |
| 174 | Bytes: certBytes, |
| 175 | }) |
| 176 | if err != nil { |
| 177 | return fmt.Errorf("writeCertificate: %w", err) |
| 178 | } |
| 179 | |
| 180 | err = file.Close() |
| 181 | if err != nil { |
| 182 | return fmt.Errorf("writeCertificate: %w", err) |
| 183 | } |
| 184 | |
| 185 | return nil |
| 186 | } |