#include <openssl/ecdh.h>
#endif
-#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_NETWARE)
-# define NO_FORK 1
-#elif HAVE_FORK
-# undef NO_FORK
+#ifndef HAVE_FORK
+# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_NETWARE)
+# define HAVE_FORK 0
+# else
+# define HAVE_FORK 1
+# endif
+#endif
+
+#if HAVE_FORK
+#undef NO_FORK
#else
-# define NO_FORK 1
+#define NO_FORK
#endif
#undef BUFSIZE
return ext_der;
}
+static void delete_ext(STACK_OF(X509_EXTENSION) *sk, X509_EXTENSION *dext)
+ {
+ int idx;
+ ASN1_OBJECT *obj;
+ obj = X509_EXTENSION_get_object(dext);
+ while ((idx = X509_EXTENSION_get_by_OBJ(sk, obj, -1)) >= 0)
+ {
+ X509_EXTENSION *tmpext= X509_get_ext(sk, idx);
+ X509_del_ext(sk, idx);
+ X509_EXTENSION_free(tmpext);
+ }
+ }
+
/* This is the main function: add a bunch of extensions based on a config file
* section to an extension STACK.
*/
val = sk_CONF_VALUE_value(nval, i);
if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)))
return 0;
+ if (ctx->flags == X509V3_CTX_FLAG_REPLACE)
+ delete_ext(*sk, ext);
if (sk) X509v3_add_ext(sk, ext, -1);
X509_EXTENSION_free(ext);
}