Go to the documentation of this file.
41 #define ovpn_err(fmt, ...) \
42 plugin->log(PLOG_ERR, "SSO", fmt, ## __VA_ARGS__)
43 #define ovpn_dbg(fmt, ...) \
44 plugin->log(PLOG_DEBUG, "SSO", fmt, ## __VA_ARGS__)
45 #define ovpn_note(fmt, ...) \
46 plugin->log(PLOG_NOTE, "SSO", fmt, ## __VA_ARGS__)
68 get_env(
const char *name,
const char *envp[])
73 const int namelen = strlen(name);
74 for (i = 0; envp[i]; ++i)
76 if (!strncmp(envp[i], name, namelen))
78 const char *cp = envp[i] + namelen;
98 printf(
"PLUGIN: allocating memory for context failed\n");
122 X509_NAME *x509_name;
123 X509_NAME_ENTRY *ent;
126 x509_name = X509_get_subject_name(x509);
127 int i, n = X509_NAME_entry_count(x509_name);
128 for (i = 0; i < n; ++i)
130 if (!(ent = X509_NAME_get_entry(x509_name, i)))
134 if (!(fn = X509_NAME_ENTRY_get_object(ent)))
138 if (!(val = X509_NAME_ENTRY_get_data(ent)))
142 if ((fn_nid = OBJ_obj2nid(fn)) == NID_undef)
146 if (!(objbuf = OBJ_nid2sn(fn_nid)))
150 unsigned char *buf = NULL;
151 if (ASN1_STRING_to_UTF8(&buf, val) < 0)
156 if (!strncasecmp(objbuf,
"CN", 2))
158 strncpy(sess->
user, (
char *)buf,
sizeof(sess->
user) - 1);
179 ovpn_err(
"this example plugin requires client certificate");
192 if (!(
f = fopen(file,
"w+")))
197 fprintf(
f,
"%s", content);
208 snprintf(file,
sizeof(file) - 1,
"/tmp/openvpn_sso_%s", sess->key);
219 char *file =
"/tmp/openvpn_sso_user";
237 strncpy(sess->key,
key,
sizeof(sess->key) - 1);
238 ovpn_note(
"app session key: %s", sess->key);
251 ovpn_note(
"app session user: %s", sess->user);
275 struct session *sess = calloc(1,
sizeof(*sess));
static const char * get_env(const char *name, const char *envp[])
openvpn_plugin_handle_t handle
Arguments used to transport variables to the plug-in.
static void file_store(char *file, char *content)
static int tls_verify(struct openvpn_plugin_args_func_in const *args)
OPENVPN_EXPORT int openvpn_plugin_open_v3(const int version, struct openvpn_plugin_args_open_in const *args, struct openvpn_plugin_args_open_return *rv)
void(* plugin_log_t)(openvpn_plugin_log_flags_t flags, const char *plugin_name, const char *format,...) _ovpn_chk_fmt(3
#define OPENVPN_PLUGIN_MASK(x)
static void client_store(struct openvpn_plugin_args_func_in const *args)
Container for unidirectional cipher and HMAC key material.
OPENVPN_EXPORT void openvpn_plugin_close_v1(openvpn_plugin_handle_t handle)
#define OPENVPN_PLUGIN_FUNC_ERROR
openvpn_x509_cert_t * current_cert
static int tls_final(struct openvpn_plugin_args_func_in const *args, struct openvpn_plugin_args_func_return *rv)
OPENVPN_EXPORT void * openvpn_plugin_client_constructor_v1(openvpn_plugin_handle_t handle)
void * per_client_context
#define OPENVPN_PLUGIN_TLS_VERIFY
Arguments used to transport variables to and from the plug-in.
static void session_user_set(struct session *sess, X509 *x509)
Arguments used to transport variables from the plug-in back to the OpenVPN process.
static void server_store(struct openvpn_plugin_args_func_in const *args)
Arguments used to transport variables to and from the plug-in.
openvpn_plugin_handle_t handle
#define OPENVPN_PLUGIN_FUNC_SUCCESS
#define OPENVPN_PLUGIN_TLS_FINAL
#define ovpn_err(fmt,...)
#define ovpn_note(fmt,...)
void * openvpn_plugin_handle_t
struct openvpn_plugin_callbacks * callbacks
OPENVPN_EXPORT int openvpn_plugin_func_v3(const int version, struct openvpn_plugin_args_func_in const *args, struct openvpn_plugin_args_func_return *rv)
OPENVPN_EXPORT void openvpn_plugin_client_destructor_v1(openvpn_plugin_handle_t handle, void *ctx)