diff options
| -rwxr-xr-x | vchat-ssl.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/vchat-ssl.c b/vchat-ssl.c index 79092a6..1a88b6c 100755 --- a/vchat-ssl.c +++ b/vchat-ssl.c | |||
| @@ -103,17 +103,17 @@ SSL_CTX * vc_create_sslctx( vc_x509store_t *vc_store ) | |||
| 103 | if(vc_store->use_certfile) | 103 | if(vc_store->use_certfile) |
| 104 | SSL_CTX_use_certificate_chain_file(ctx, vc_store->use_certfile); | 104 | SSL_CTX_use_certificate_chain_file(ctx, vc_store->use_certfile); |
| 105 | else { | 105 | else { |
| 106 | SSL_CTX_use_certificate(ctx, | 106 | SSL_CTX_use_certificate(ctx, |
| 107 | sk_X509_value(vc_store->use_certs, 0)); | 107 | sk_X509_value(vc_store->use_certs, 0)); |
| 108 | for(i=0,n=sk_X509_num(vc_store->use_certs); i<n; i++) | 108 | for(i=0,n=sk_X509_num(vc_store->use_certs); i<n; i++) |
| 109 | SSL_CTX_add_extra_chain_cert(ctx, | 109 | SSL_CTX_add_extra_chain_cert(ctx, |
| 110 | sk_X509_value(vc_store->use_certs, i)); | 110 | sk_X509_value(vc_store->use_certs, i)); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | SSL_CTX_set_default_passwd_cb(ctx, vc_store->askpass_callback); | 113 | SSL_CTX_set_default_passwd_cb(ctx, vc_store->askpass_callback); |
| 114 | 114 | ||
| 115 | if(vc_store->use_keyfile) { | 115 | if(vc_store->use_keyfile) { |
| 116 | r=SSL_CTX_use_PrivateKey_file(ctx, vc_store->use_keyfile, | 116 | r=SSL_CTX_use_PrivateKey_file(ctx, vc_store->use_keyfile, |
| 117 | SSL_FILETYPE_PEM); | 117 | SSL_FILETYPE_PEM); |
| 118 | } else if(vc_store->use_key) | 118 | } else if(vc_store->use_key) |
| 119 | r=SSL_CTX_use_PrivateKey(ctx, vc_store->use_key); | 119 | r=SSL_CTX_use_PrivateKey(ctx, vc_store->use_key); |
| @@ -263,16 +263,16 @@ X509_STORE *vc_x509store_create(vc_x509store_t *vc_store) | |||
| 263 | if(!vc_store->cafile) { | 263 | if(!vc_store->cafile) { |
| 264 | if( !(vc_store->flags & VC_X509S_NODEF_CAFILE) ) | 264 | if( !(vc_store->flags & VC_X509S_NODEF_CAFILE) ) |
| 265 | X509_LOOKUP_load_file(lookup, 0, X509_FILETYPE_DEFAULT); | 265 | X509_LOOKUP_load_file(lookup, 0, X509_FILETYPE_DEFAULT); |
| 266 | } else if( !X509_LOOKUP_load_file(lookup, vc_store->cafile, | 266 | } else if( !X509_LOOKUP_load_file(lookup, vc_store->cafile, |
| 267 | X509_FILETYPE_PEM) ) | 267 | X509_FILETYPE_PEM) ) |
| 268 | VC_STORE_ERR_EXIT(store); | 268 | VC_STORE_ERR_EXIT(store); |
| 269 | 269 | ||
| 270 | if(vc_store->crlfile) { | 270 | if(vc_store->crlfile) { |
| 271 | if( !X509_load_crl_file(lookup, vc_store->crlfile, | 271 | if( !X509_load_crl_file(lookup, vc_store->crlfile, |
| 272 | X509_FILETYPE_PEM) ) | 272 | X509_FILETYPE_PEM) ) |
| 273 | VC_STORE_ERR_EXIT(store); | 273 | VC_STORE_ERR_EXIT(store); |
| 274 | 274 | ||
| 275 | X509_STORE_set_flags( store, | 275 | X509_STORE_set_flags( store, |
| 276 | X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL ); | 276 | X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL ); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| @@ -282,7 +282,7 @@ X509_STORE *vc_x509store_create(vc_x509store_t *vc_store) | |||
| 282 | if( !vc_store->capath ) { | 282 | if( !vc_store->capath ) { |
| 283 | if( !(vc_store->flags & VC_X509S_NODEF_CAPATH) ) | 283 | if( !(vc_store->flags & VC_X509S_NODEF_CAPATH) ) |
| 284 | X509_LOOKUP_add_dir(lookup, 0, X509_FILETYPE_DEFAULT); | 284 | X509_LOOKUP_add_dir(lookup, 0, X509_FILETYPE_DEFAULT); |
| 285 | } else if( !X509_LOOKUP_add_dir(lookup, vc_store->capath, | 285 | } else if( !X509_LOOKUP_add_dir(lookup, vc_store->capath, |
| 286 | X509_FILETYPE_PEM) ) | 286 | X509_FILETYPE_PEM) ) |
| 287 | VC_STORE_ERR_EXIT(store); | 287 | VC_STORE_ERR_EXIT(store); |
| 288 | 288 | ||
| @@ -291,8 +291,8 @@ X509_STORE *vc_x509store_create(vc_x509store_t *vc_store) | |||
| 291 | VC_STORE_ERR_EXIT(store); | 291 | VC_STORE_ERR_EXIT(store); |
| 292 | 292 | ||
| 293 | for( i=0, n=sk_X509_CRL_num(vc_store->crls); i<n; i++) | 293 | for( i=0, n=sk_X509_CRL_num(vc_store->crls); i<n; i++) |
| 294 | if( !X509_STORE_add_crl(store, | 294 | if( !X509_STORE_add_crl(store, |
| 295 | sk_X509_CRL_value(vc_store->crls, i)) ) | 295 | sk_X509_CRL_value(vc_store->crls, i)) ) |
| 296 | VC_STORE_ERR_EXIT(store); | 296 | VC_STORE_ERR_EXIT(store); |
| 297 | 297 | ||
| 298 | return(store); | 298 | return(store); |
| @@ -301,7 +301,7 @@ X509_STORE *vc_x509store_create(vc_x509store_t *vc_store) | |||
| 301 | int vc_verify_callback(int ok, X509_STORE_CTX *store) | 301 | int vc_verify_callback(int ok, X509_STORE_CTX *store) |
| 302 | { | 302 | { |
| 303 | if(!ok) { | 303 | if(!ok) { |
| 304 | snprintf(tmpstr, TMPSTRSIZE, "[SSL VERIFY ERROR ] %s", | 304 | snprintf(tmpstr, TMPSTRSIZE, "[SSL VERIFY ERROR ] %s", |
| 305 | X509_verify_cert_error_string(store->error)); | 305 | X509_verify_cert_error_string(store->error)); |
| 306 | writecf(FS_ERR, tmpstr); | 306 | writecf(FS_ERR, tmpstr); |
| 307 | } | 307 | } |
| @@ -318,13 +318,13 @@ void vc_x509store_clearflags(vc_x509store_t *store, int flags) | |||
| 318 | store->flags &= ~flags; | 318 | store->flags &= ~flags; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | void vc_x509store_setcb(vc_x509store_t *store, | 321 | void vc_x509store_setcb(vc_x509store_t *store, |
| 322 | vc_x509verify_cb_t callback) | 322 | vc_x509verify_cb_t callback) |
| 323 | { | 323 | { |
| 324 | store->callback = callback; | 324 | store->callback = callback; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | void vc_x509store_set_pkeycb(vc_x509store_t *store, | 327 | void vc_x509store_set_pkeycb(vc_x509store_t *store, |
| 328 | vc_askpass_cb_t callback) | 328 | vc_askpass_cb_t callback) |
| 329 | { | 329 | { |
| 330 | store->askpass_callback = callback; | 330 | store->askpass_callback = callback; |
| @@ -335,31 +335,31 @@ void vc_x509store_addcert(vc_x509store_t *store, X509 *cert) | |||
| 335 | sk_X509_push(store->certs, cert); | 335 | sk_X509_push(store->certs, cert); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | void vc_x509store_setcafile(vc_x509store_t *store, char *file) | 338 | void vc_x509store_setcafile(vc_x509store_t *store, char *file) |
| 339 | { | 339 | { |
| 340 | free(store->cafile); | 340 | free(store->cafile); |
| 341 | store->cafile = ( file ? strdup(file) : 0 ); | 341 | store->cafile = ( file ? strdup(file) : 0 ); |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | void vc_x509store_setcapath(vc_x509store_t *store, char *path) | 344 | void vc_x509store_setcapath(vc_x509store_t *store, char *path) |
| 345 | { | 345 | { |
| 346 | free(store->capath); | 346 | free(store->capath); |
| 347 | store->capath = ( path ? strdup(path) : 0 ); | 347 | store->capath = ( path ? strdup(path) : 0 ); |
| 348 | } | 348 | } |
| 349 | 349 | ||
| 350 | void vc_x509store_setcrlfile(vc_x509store_t *store, char *file) | 350 | void vc_x509store_setcrlfile(vc_x509store_t *store, char *file) |
| 351 | { | 351 | { |
| 352 | free(store->crlfile); | 352 | free(store->crlfile); |
| 353 | store->crlfile = ( file ? strdup(file) : 0 ); | 353 | store->crlfile = ( file ? strdup(file) : 0 ); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | void vc_x509store_setkeyfile(vc_x509store_t *store, char *file) | 356 | void vc_x509store_setkeyfile(vc_x509store_t *store, char *file) |
| 357 | { | 357 | { |
| 358 | free(store->use_keyfile); | 358 | free(store->use_keyfile); |
| 359 | store->use_keyfile = ( file ? strdup(file) : 0 ); | 359 | store->use_keyfile = ( file ? strdup(file) : 0 ); |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | void vc_x509store_setcertfile(vc_x509store_t *store, char *file) | 362 | void vc_x509store_setcertfile(vc_x509store_t *store, char *file) |
| 363 | { | 363 | { |
| 364 | free(store->use_certfile); | 364 | free(store->use_certfile); |
| 365 | store->use_certfile = ( file ? strdup(file) : 0 ); | 365 | store->use_certfile = ( file ? strdup(file) : 0 ); |
