e_os.h does not belong with the exported headers. Do not put it there
[openssl.git] / apps / s_cb.c
index 712a043..fd62259 100644 (file)
@@ -1,5 +1,5 @@
-/* apps/s_cb.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* apps/s_cb.c - callback functions used by s_client, s_server, and s_time */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
 #include "apps.h"
 #undef NON_MAIN
 #undef USE_SOCKETS
-#include "err.h"
-#include "x509.h"
-#include "ssl.h"
+#include <openssl/err.h>
+#include <openssl/x509.h>
+#include <openssl/ssl.h>
 #include "s_apps.h"
 
 int verify_depth=0;
 int verify_error=X509_V_OK;
 
-/* should be X509 * but we can just have them as char *. */
-int MS_CALLBACK verify_callback(ok, ctx)
-int ok;
-X509_STORE_CTX *ctx;
+int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
        {
        char buf[256];
        X509 *err_cert;
@@ -110,13 +107,13 @@ X509_STORE_CTX *ctx;
        case X509_V_ERR_CERT_NOT_YET_VALID:
        case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
                BIO_printf(bio_err,"notBefore=");
-               ASN1_UTCTIME_print(bio_err,X509_get_notBefore(ctx->current_cert));
+               ASN1_TIME_print(bio_err,X509_get_notBefore(ctx->current_cert));
                BIO_printf(bio_err,"\n");
                break;
        case X509_V_ERR_CERT_HAS_EXPIRED:
        case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
                BIO_printf(bio_err,"notAfter=");
-               ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ctx->current_cert));
+               ASN1_TIME_print(bio_err,X509_get_notAfter(ctx->current_cert));
                BIO_printf(bio_err,"\n");
                break;
                }
@@ -124,20 +121,19 @@ X509_STORE_CTX *ctx;
        return(ok);
        }
 
-int set_cert_stuff(ctx, cert_file, key_file)
-SSL_CTX *ctx;
-char *cert_file;
-char *key_file;
+int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file)
        {
        if (cert_file != NULL)
                {
+               /*
                SSL *ssl;
                X509 *x509;
+               */
 
                if (SSL_CTX_use_certificate_file(ctx,cert_file,
                        SSL_FILETYPE_PEM) <= 0)
                        {
-                       BIO_printf(bio_err,"unable to set certificate file\n");
+                       BIO_printf(bio_err,"unable to get certificate from '%s'\n",cert_file);
                        ERR_print_errors(bio_err);
                        return(0);
                        }
@@ -145,18 +141,25 @@ char *key_file;
                if (SSL_CTX_use_PrivateKey_file(ctx,key_file,
                        SSL_FILETYPE_PEM) <= 0)
                        {
-                       BIO_printf(bio_err,"unable to set public key file\n");
+                       BIO_printf(bio_err,"unable to get private key from '%s'\n",key_file);
                        ERR_print_errors(bio_err);
                        return(0);
                        }
 
+               /*
+               In theory this is no longer needed 
                ssl=SSL_new(ctx);
                x509=SSL_get_certificate(ssl);
 
-               if (x509 != NULL)
-                       EVP_PKEY_copy_parameters(X509_get_pubkey(x509),
-                               SSL_get_privatekey(ssl));
+               if (x509 != NULL) {
+                       EVP_PKEY *pktmp;
+                       pktmp = X509_get_pubkey(x509);
+                       EVP_PKEY_copy_parameters(pktmp,
+                                               SSL_get_privatekey(ssl));
+                       EVP_PKEY_free(pktmp);
+               }
                SSL_free(ssl);
+               */
 
                /* If we are using DSA, we can copy the parameters from
                 * the private key */
@@ -173,13 +176,8 @@ char *key_file;
        return(1);
        }
 
-long MS_CALLBACK bio_dump_cb(bio,cmd,argp,argi,argl,ret)
-BIO *bio;
-int cmd;
-char *argp;
-int argi;
-long argl;
-long ret;
+long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp, int argi,
+            long argl, long ret)
        {
        BIO *out;
 
@@ -202,10 +200,7 @@ long ret;
        return(ret);
        }
 
-void MS_CALLBACK apps_ssl_info_callback(s,where,ret)
-SSL *s;
-int where;
-int ret;
+void MS_CALLBACK apps_ssl_info_callback(SSL *s, int where, int ret)
        {
        char *str;
        int w;