VMS updates.
[openssl.git] / apps / s_client.c
index cea00788a6a75dbc99ae8681296c5c7ef16a6195..96e446c2a491cb0df9ba75b74982f58319630bfc 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef NO_STDIO
+#define APPS_WIN16
+#endif
+
 /* With IPv6, it looks like Digital has mixed up the proper order of
    recursive header file inclusion, resulting in the compiler complaining
    that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
    is needed to have fileno() declared correctly...  So let's define u_int */
-#if defined(__DECC) && !defined(__U_INT)
+#if defined(VMS) && defined(__DECC) && !defined(__U_INT)
 #define __U_INT
 typedef unsigned int u_int;
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #define USE_SOCKETS
-#ifdef NO_STDIO
-#define APPS_WIN16
-#endif
 #include "apps.h"
 #include <openssl/x509.h>
 #include <openssl/ssl.h>
@@ -555,6 +556,9 @@ re_start:
 #ifndef WINDOWS
                else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
                        {
+#ifdef CHARSET_EBCDIC
+                       ascii2ebcdic(&(sbuf[sbuf_off]),&(sbuf[sbuf_off]),sbuf_len);
+#endif
                        i=write(fileno(stdout),&(sbuf[sbuf_off]),sbuf_len);
 
                        if (i <= 0)
@@ -648,6 +652,9 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
                                {
                                cbuf_len=i;
                                cbuf_off=0;
+#ifdef CHARSET_EBCDIC
+                               ebcdic2ascii(cbuf, cbuf, i);
+#endif
                                }
 
                        write_ssl=1;
@@ -688,9 +695,13 @@ static void print_stuff(BIO *bio, SSL *s, int full)
 
        if (full)
                {
+               int got_a_chain = 0;
+
                sk=SSL_get_peer_cert_chain(s);
                if (sk != NULL)
                        {
+                       got_a_chain = 1; /* we don't have it for SSL2 (yet) */
+
                        BIO_printf(bio,"---\nCertificate chain\n");
                        for (i=0; i<sk_X509_num(sk); i++)
                                {
@@ -710,7 +721,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
                if (peer != NULL)
                        {
                        BIO_printf(bio,"Server certificate\n");
-                       if (!c_showcerts) /* Redundant if we showed the whole chain */
+                       if (!(c_showcerts && got_a_chain)) /* Redundant if we showed the whole chain */
                                PEM_write_bio_X509(bio,peer);
                        X509_NAME_oneline(X509_get_subject_name(peer),
                                buf,BUFSIZ);