| 331 | |
| 332 | |
| 333 | Try<Nothing> write_certificate_file(X509* x509, const Path& path) |
| 334 | { |
| 335 | // We use 'FILE*' here because it is an API requirement by openssl. |
| 336 | FILE* file = fopen(path.string().c_str(), "wb"); |
| 337 | if (file == nullptr) { |
| 338 | return Error("Failed to open file '" + stringify(path) + "' for writing"); |
| 339 | } |
| 340 | |
| 341 | if (PEM_write_X509(file, x509) != 1) { |
| 342 | fclose(file); |
| 343 | return Error("Failed to write certificate to file '" + stringify(path) + |
| 344 | "': PEM_write_X509"); |
| 345 | } |
| 346 | |
| 347 | fclose(file); |
| 348 | |
| 349 | return Nothing(); |
| 350 | } |
| 351 | |
| 352 | |
| 353 | Try<string> generate_hmac_sha256( |