Skip to content

Commit

Permalink
speed up cert setting via cert type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Oct 22, 2020
1 parent c83efe8 commit 195e8e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,19 +820,25 @@ NOEXPORT void ssl_start(CLI *c) {
{
char * cert = j == 0 ? c->opt->cert : c->opt->cert2;
char * pin = j == 0 ? c->opt->pin : c->opt->pin2;
char * pcerttype = j == 0 ? &c->opt->certtype : &c->opt->certtype2;
char certtype = *pcerttype;
char is_ok = 0;
char is_pfx = 0;

if( !cert )
{
is_ok = 1;
}
else if( msspi_add_mycert( c->msh, cert, 0 ) )
else if( ( certtype == 0 || certtype == 1 ) && msspi_add_mycert( c->msh, cert, 0 ) )
{
certtype = 1;
*pcerttype = certtype;
is_ok = 1;
}
else if( pin && msspi_add_mycert_pfx( c->msh, cert, strlen( cert ), pin ) )
else if( pin && ( certtype == 0 || certtype == 2 ) && msspi_add_mycert_pfx( c->msh, cert, strlen( cert ), pin ) )
{
certtype = 2;
*pcerttype = certtype;
is_ok = 1;
is_pfx = 1;
}
Expand Down Expand Up @@ -879,13 +885,17 @@ NOEXPORT void ssl_start(CLI *c) {
errstr = "can not read file";
break;
}
if( msspi_add_mycert( c->msh, (char *)str_file, (int)size_file ) )
if( ( certtype == 0 || certtype == 3 ) && msspi_add_mycert( c->msh, (char *)str_file, (int)size_file ) )
{
certtype = 3;
*pcerttype = certtype;
is_ok = 1;
break;
}
if( pin && msspi_add_mycert_pfx( c->msh, (char *)str_file, (int)size_file, pin ) )
if( pin && ( certtype == 0 || certtype == 4 ) && msspi_add_mycert_pfx( c->msh, (char *)str_file, (int)size_file, pin ) )
{
certtype = 4;
*pcerttype = certtype;
is_ok = 1;
is_pfx = 1;
break;
Expand Down
2 changes: 2 additions & 0 deletions src/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ typedef struct service_options_struct {
char *pin2; /* pin-code for second cert */
NAME_LIST * checkSubject; /* strcmp cert subject */
NAME_LIST * checkIssuer; /* strcmp cert issuer */
char certtype; /* cert type detector */
char certtype2; /* cert2 type detector */
#endif
long session_size, session_timeout;
#if OPENSSL_VERSION_NUMBER>=0x10100000L
Expand Down

0 comments on commit 195e8e5

Please sign in to comment.