29#include "openvpn-plugin.h"
31#define PLUGIN_NAME "base64.c"
58get_env(
const char *name,
const char *envp[])
63 const int namelen = strlen(name);
64 for (i = 0; envp[i]; ++i)
66 if (!strncmp(envp[i], name, namelen))
68 const char *cp = envp[i] + namelen;
104 struct openvpn_plugin_args_open_in
const *args,
105 struct openvpn_plugin_args_open_return *ret)
108 if (v3structver != OPENVPN_PLUGINv3_STRUCTVER)
110 printf(
"base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n");
111 return OPENVPN_PLUGIN_FUNC_ERROR;
116 OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_TLS_VERIFY)
117 |OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT_V2);
120 ret->handle = calloc(1, 1);
123 ovpn_log = args->callbacks->plugin_log;
124 ovpn_vlog = args->callbacks->plugin_vlog;
130 args->ovpn_version, args->ovpn_version_major,
131 args->ovpn_version_minor, args->ovpn_version_patch);
133 return OPENVPN_PLUGIN_FUNC_SUCCESS;
161 if (type != OPENVPN_PLUGIN_TLS_VERIFY
162 && type != OPENVPN_PLUGIN_CLIENT_CONNECT_V2)
165 return OPENVPN_PLUGIN_FUNC_ERROR;
169 const char *clcert_cn =
get_env(
"X509_0_CN", envp);
173 return OPENVPN_PLUGIN_FUNC_SUCCESS;
183 char buf2[256] = {0};
189 r = strcmp(clcert_cn, buf2);
192 return (r == 0) ? OPENVPN_PLUGIN_FUNC_SUCCESS : OPENVPN_PLUGIN_FUNC_ERROR;
OPENVPN_EXPORT int openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
This function is called by OpenVPN each time the OpenVPN reaches a point where plug-in calls should h...
OPENVPN_EXPORT void openvpn_plugin_close_v1(openvpn_plugin_handle_t handle)
This cleans up the last part of the plug-in, allows it to shut down cleanly and release the plug-in g...
plugin_log_t ovpn_log
Pointer to the OpenVPN log function.
plugin_base64_decode_t ovpn_base64_decode
Pointer to the openvpn_base64_decode () function.
plugin_base64_encode_t ovpn_base64_encode
Pointer to the openvpn_base64_encode () function.
plugin_vlog_t ovpn_vlog
Pointer to the OpenVPN vlog function.
static const char * get_env(const char *name, const char *envp[])
Search the environment pointer for a specific env var name.
OPENVPN_EXPORT int openvpn_plugin_open_v3(const int v3structver, struct openvpn_plugin_args_open_in const *args, struct openvpn_plugin_args_open_return *ret)
This function is called when OpenVPN loads the plug-in.
Contains all state information for one tunnel.