X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fsess_id.c;h=8ac118d4a1e6e013ea70fc5c3a83760483b0c0de;hp=4a2d9f8ab3dccfb16e0e416bd4ec48f5658b2f4e;hb=3a4f14f3d178581c746b5c575acc2b0118563048;hpb=7ae01d4adc752241cbf49db74d2510d30fc2d923 diff --git a/apps/sess_id.c b/apps/sess_id.c index 4a2d9f8ab3..8ac118d4a1 100644 --- a/apps/sess_id.c +++ b/apps/sess_id.c @@ -60,11 +60,11 @@ #include #include #include "apps.h" -#include "bio.h" -#include "err.h" -#include "x509.h" -#include "pem.h" -#include "ssl.h" +#include +#include +#include +#include +#include #undef PROG #define PROG sess_id_main @@ -77,26 +77,20 @@ static char *sess_id_usage[]={ " -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 }; -#ifndef NOPROTO static SSL_SESSION *load_sess_id(char *file, int format); -#else -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 +134,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 +161,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 +264,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; @@ -281,7 +289,7 @@ int format; if (format == FORMAT_ASN1) x=d2i_SSL_SESSION_bio(in,NULL); else if (format == FORMAT_PEM) - x=PEM_read_bio_SSL_SESSION(in,NULL,NULL); + x=PEM_read_bio_SSL_SESSION(in,NULL,NULL,NULL); else { BIO_printf(bio_err,"bad input format specified for input crl\n"); goto end;