29#include "openvpn-plugin.h"
31#define PLUGIN_NAME "base64.c"
54get_env(
const char *name,
const char *envp[])
59 const int namelen = strlen(name);
60 for (i = 0; envp[i]; ++i)
62 if (!strncmp(envp[i], name, namelen))
64 const char *cp = envp[i] + namelen;
100 struct openvpn_plugin_args_open_in
const *args,
101 struct openvpn_plugin_args_open_return *ret)
104 if (v3structver != OPENVPN_PLUGINv3_STRUCTVER)
106 printf(
"base64.c: ** ERROR ** Incompatible plug-in interface between this plug-in and OpenVPN\n");
107 return OPENVPN_PLUGIN_FUNC_ERROR;
112 OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_TLS_VERIFY)
113 |OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT_V2);
116 ret->handle = calloc(1, 1);
119 ovpn_log = args->callbacks->plugin_log;
120 ovpn_vlog = args->callbacks->plugin_vlog;
126 args->ovpn_version, args->ovpn_version_major,
127 args->ovpn_version_minor, args->ovpn_version_patch);
129 return OPENVPN_PLUGIN_FUNC_SUCCESS;
157 if (type != OPENVPN_PLUGIN_TLS_VERIFY
158 && type != OPENVPN_PLUGIN_CLIENT_CONNECT_V2)
161 return OPENVPN_PLUGIN_FUNC_ERROR;
165 const char *clcert_cn =
get_env(
"X509_0_CN", envp);
169 return OPENVPN_PLUGIN_FUNC_SUCCESS;
179 char buf2[256] = {0};
185 r = strcmp(clcert_cn, buf2);
188 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.