RT3548: Remove unsupported platforms
[openssl.git] / apps / x509.c
index 51c86b4139c029a5aaaab996a28737d176680e4f..b3c23907bf74966996b1318a56ab4d7533c5a9b6 100644 (file)
@@ -60,9 +60,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef OPENSSL_NO_STDIO
-#define APPS_WIN16
-#endif
 #include "apps.h"
 #include <openssl/bio.h>
 #include <openssl/asn1.h>
@@ -156,7 +153,7 @@ static const char *x509_usage[]={
 NULL
 };
 
-static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx);
+static int callb(int ok, X509_STORE_CTX *ctx);
 static int sign (X509 *x, EVP_PKEY *pkey,int days,int clrext, const EVP_MD *digest,
                                                CONF *conf, char *section);
 static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
@@ -166,6 +163,9 @@ static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
                         CONF *conf, char *section, ASN1_INTEGER *sno);
 static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
 static int reqfile=0;
+#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
+static int force_version=2;
+#endif
 
 int MAIN(int, char **);
 
@@ -211,7 +211,8 @@ int MAIN(int argc, char **argv)
        int need_rand = 0;
        int checkend=0,checkoffset=0;
        unsigned long nmflag = 0, certflag = 0;
-       unsigned char *checkhost = NULL, *checkemail = NULL;
+       char *checkhost = NULL;
+       char *checkemail = NULL;
        char *checkip = NULL;
 #ifndef OPENSSL_NO_ENGINE
        char *engine=NULL;
@@ -288,6 +289,13 @@ int MAIN(int argc, char **argv)
                        if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
                                goto bad;
                        }
+#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
+               else if (strcmp(*argv,"-force_version") == 0)
+                       {
+                       if (--argc < 1) goto bad;
+                       force_version=atoi(*(++argv)) - 1;
+                       }
+#endif
                else if (strcmp(*argv,"-days") == 0)
                        {
                        if (--argc < 1) goto bad;
@@ -464,12 +472,12 @@ int MAIN(int argc, char **argv)
                else if (strcmp(*argv,"-checkhost") == 0)
                        {
                        if (--argc < 1) goto bad;
-                       checkhost=(unsigned char *)*(++argv);
+                       checkhost=*(++argv);
                        }
                else if (strcmp(*argv,"-checkemail") == 0)
                        {
                        if (--argc < 1) goto bad;
-                       checkemail=(unsigned char *)*(++argv);
+                       checkemail=*(++argv);
                        }
                else if (strcmp(*argv,"-checkip") == 0)
                        {
@@ -1247,7 +1255,11 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
        if (conf)
                {
                X509V3_CTX ctx2;
+#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
+               X509_set_version(x, force_version);
+#else
                X509_set_version(x,2); /* version 3 certificate */
+#endif
                 X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);
                 X509V3_set_nconf(&ctx2, conf);
                 if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end;
@@ -1264,7 +1276,7 @@ end:
        return ret;
        }
 
-static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx)
+static int callb(int ok, X509_STORE_CTX *ctx)
        {
        int err;
        X509 *err_cert;
@@ -1325,7 +1337,11 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *dig
        if (conf)
                {
                X509V3_CTX ctx;
+#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
+               X509_set_version(x, force_version);
+#else
                X509_set_version(x,2); /* version 3 certificate */
+#endif
                 X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
                 X509V3_set_nconf(&ctx, conf);
                 if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;