MCPcopy Create free account
hub / github.com/3rdparty/libprocess / write_key_file

Function write_key_file

src/ssl/utilities.cpp:312–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310
311
312Try<Nothing> write_key_file(EVP_PKEY* private_key, const Path& path)
313{
314 // We use 'FILE*' here because it is an API requirement by openssl.
315 FILE* file = fopen(path.string().c_str(), "wb");
316 if (file == nullptr) {
317 return Error("Failed to open file '" + stringify(path) + "' for writing");
318 }
319
320 if (PEM_write_PrivateKey(
321 file, private_key, nullptr, nullptr, 0, nullptr, nullptr) != 1) {
322 fclose(file);
323 return Error("Failed to write private key to file '" + stringify(path) +
324 "': PEM_write_PrivateKey");
325 }
326
327 fclose(file);
328
329 return Nothing();
330}
331
332
333Try<Nothing> write_certificate_file(X509* x509, const Path& path)

Callers 1

Calls 1

stringMethod · 0.80

Tested by 1