* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <openssl/x509v3.h>
+#ifndef OPENVPN_PLUGIN_H_
+#define OPENVPN_PLUGIN_H_
+
+#ifdef USE_OPENSSL
+#include "ssl_verify_openssl.h"
+#endif
#define OPENVPN_PLUGIN_VERSION 3
openvpn_plugin_handle_t handle;
void *per_client_context;
int current_cert_depth;
- X509 *current_cert;
+ x509_cert_t *current_cert;
};
OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v1)
(openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[]);
+
+#endif /* OPENVPN_PLUGIN_H_ */
struct openvpn_plugin_string_list **retlist,
const char **envp,
int certdepth,
- X509 *current_cert)
+ x509_cert_t *current_cert)
{
int status = OPENVPN_PLUGIN_FUNC_SUCCESS;
struct plugin_return *pr,
struct env_set *es,
int certdepth,
- X509 *current_cert)
+ x509_cert_t *current_cert)
{
if (pr)
plugin_return_init (pr);
struct plugin_return *pr,
struct env_set *es,
int current_cert_depth,
- X509 *current_cert);
+ x509_cert_t *current_cert);
void plugin_list_close (struct plugin_list *pl);
bool plugin_defined (const struct plugin_list *pl, const int type);
struct plugin_return *pr,
struct env_set *es,
int current_cert_depth,
- X509 *current_cert)
+ x509_cert_t *current_cert)
{
return 0;
}
if (cert_depth == 0 && verify_peer_cert(opt, cert, subject, common_name))
goto err;
- /* call --tls-verify plug-in(s) */
- if (plugin_defined (opt->plugins, OPENVPN_PLUGIN_TLS_VERIFY))
- {
- int ret;
-
- argv_printf (&argv, "%d %s",
- cert_depth,
- subject);
-
- ret = plugin_call (opt->plugins, OPENVPN_PLUGIN_TLS_VERIFY, &argv, NULL, opt->es, cert_depth, cert);
-
- if (ret == OPENVPN_PLUGIN_FUNC_SUCCESS)
- {
- msg (D_HANDSHAKE, "VERIFY PLUGIN OK: depth=%d, %s",
- cert_depth, subject);
- }
- else
- {
- msg (D_HANDSHAKE, "VERIFY PLUGIN ERROR: depth=%d, %s",
- cert_depth, subject);
- goto err; /* Reject connection */
- }
- }
+ /* call --tls-verify plug-in(s), if registered */
+ if (verify_cert_call_plugin(opt->plugins, opt->es, cert_depth, cert, subject))
+ goto err;
/* run --tls-verify script */
if (opt->verify_command)
}
}
+/*
+ * call --tls-verify plug-in(s)
+ */
+int
+verify_cert_call_plugin(const struct plugin_list *plugins, struct env_set *es,
+ int cert_depth, x509_cert_t *cert, char *subject)
+{
+ if (plugin_defined (plugins, OPENVPN_PLUGIN_TLS_VERIFY))
+ {
+ int ret;
+ struct argv argv = argv_new ();
+
+ argv_printf (&argv, "%d %s", cert_depth, subject);
+
+ ret = plugin_call (plugins, OPENVPN_PLUGIN_TLS_VERIFY, &argv, NULL, es, cert_depth, cert);
+
+ argv_reset (&argv);
+
+ if (ret == OPENVPN_PLUGIN_FUNC_SUCCESS)
+ {
+ msg (D_HANDSHAKE, "VERIFY PLUGIN OK: depth=%d, %s",
+ cert_depth, subject);
+ }
+ else
+ {
+ msg (D_HANDSHAKE, "VERIFY PLUGIN ERROR: depth=%d, %s",
+ cert_depth, subject);
+ return 1; /* Reject connection */
+ }
+ }
+ return 0;
+}
+
/* ***************************************************************************
* Functions for the management of deferred authentication when using
verify_cert_set_env(struct env_set *es, x509_cert_t *peer_cert, int cert_depth,
const char *subject, const char *common_name,
const struct x509_track *x509_track);
+int verify_cert_call_plugin(const struct plugin_list *plugins, struct env_set *es,
+ int cert_depth, x509_cert_t *cert, char *subject);
#endif /* SSL_VERIFY_H_ */