foundationdb/FDBLibTLS/FDBLibTLSPlugin.cpp
Alex Miller 53e8a84bef Import LibreSSL TLS Plugin.
This does not integrate it into the FoundationDB build system at all, though
the original Makefile exists and could be used to build this plugin.
2018-04-12 14:13:02 -07:00

31 lines
859 B
C++

// Apple Proprietary and Confidential Information
#include "FDBLibTLSPlugin.h"
#include "FDBLibTLSPolicy.h"
#include <string.h>
FDBLibTLSPlugin::FDBLibTLSPlugin() {
// tls_init is not currently thread safe - caller's responsibility.
rc = tls_init();
}
FDBLibTLSPlugin::~FDBLibTLSPlugin() {
}
ITLSPolicy *FDBLibTLSPlugin::create_policy(ITLSLogFunc logf) {
if (rc < 0) {
// Log the failure from tls_init during our constructor.
logf("FDBLibTLSInitError", NULL, true, "LibTLSErrorMessage", "failed to initialize libtls", NULL);
return NULL;
}
return new FDBLibTLSPolicy(Reference<FDBLibTLSPlugin>::addRef(this), logf);
}
extern "C" void *get_plugin(const char *plugin_type_name_and_version) {
if (strcmp(plugin_type_name_and_version, FDBLibTLSPlugin::get_plugin_type_name_and_version()) == 0) {
return new FDBLibTLSPlugin;
}
return NULL;
}