Change #include filenames from <foo.h> to <openssl.h>.
[openssl.git] / apps / sess_id.c
index a606ca3a5cd30186e9c0b46bf47287c8c1d2c9db..11cf837267c2eeab5448c9da86862ba02131b7ae 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include "apps.h"
-#include "bio.h"
-#include "err.h"
-#include "x509.h"
-#include "pem.h"
-#include "ssl.h"
+#include <openssl/bio.h>
+#include <openssl/err.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
+#include <openssl/ssl.h>
 
 #undef PROG
 #define PROG   sess_id_main
 
 static char *sess_id_usage[]={
-"usage: crl args\n",
+"usage: sess_id args\n",
 "\n",
 " -inform arg     - input format - default PEM (one of DER, TXT or PEM)\n",
 " -outform arg    - output format - default PEM\n",
 " -in arg         - input file - default stdin\n",
 " -out arg        - output file - default stdout\n",
 " -text           - print ssl session id details\n",
-" -cert           - output certificaet \n",
+" -cert           - output certificate \n",
 " -noout          - no CRL output\n",
+" -context arg    - set the session ID context\n",
 NULL
 };
 
@@ -88,15 +89,13 @@ static SSL_SESSION *load_sess_id(char *file, int format);
 static SSL_SESSION *load_sess_id();
 #endif
 
-int MAIN(argc, argv)
-int argc;
-char **argv;
+int MAIN(int argc, char **argv)
        {
        SSL_SESSION *x=NULL;
        int ret=1,i,num,badops=0;
        BIO *out=NULL;
        int informat,outformat;
-       char *infile=NULL,*outfile=NULL;
+       char *infile=NULL,*outfile=NULL,*context=NULL;
        int cert=0,noout=0,text=0;
        char **pp;
 
@@ -140,6 +139,11 @@ char **argv;
                        cert= ++num;
                else if (strcmp(*argv,"-noout") == 0)
                        noout= ++num;
+               else if (strcmp(*argv,"-context") == 0)
+                   {
+                   if(--argc < 1) goto bad;
+                   context=*++argv;
+                   }
                else
                        {
                        BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -162,6 +166,17 @@ bad:
        x=load_sess_id(infile,informat);
        if (x == NULL) { goto end; }
 
+       if(context)
+           {
+           x->sid_ctx_length=strlen(context);
+           if(x->sid_ctx_length > SSL_MAX_SID_CTX_LENGTH)
+               {
+               BIO_printf(bio_err,"Context too long\n");
+               goto end;
+               }
+           memcpy(x->sid_ctx,context,x->sid_ctx_length);
+           }
+
 #ifdef undef
        /* just testing for memory leaks :-) */
        {
@@ -254,9 +269,7 @@ end:
        EXIT(ret);
        }
 
-static SSL_SESSION *load_sess_id(infile, format)
-char *infile;
-int format;
+static SSL_SESSION *load_sess_id(char *infile, int format)
        {
        SSL_SESSION *x=NULL;
        BIO *in=NULL;