X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=ssl%2Fssl_cert.c;h=d78584715a7589a175a708b5c2a8a225c25ab04f;hp=fcd6ff90b6f48487c0d9448596daeec0bd29ca11;hb=a3faebd1041576a59bffe01bbd2c68495870ec5e;hpb=79aa04ef27f69a1149d4d0e72d2d2953b6241ef0 diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index fcd6ff90b6..d78584715a 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -115,6 +115,10 @@ #include #endif +#if defined(WIN32) +#include +#endif + #ifdef NeXT #include #define dirent direct @@ -190,7 +194,7 @@ CERT *ssl_cert_dup(CERT *cert) #ifndef OPENSSL_NO_RSA if (cert->rsa_tmp != NULL) { - RSA_up(cert->rsa_tmp); + RSA_up_ref(cert->rsa_tmp); ret->rsa_tmp = cert->rsa_tmp; } ret->rsa_tmp_cb = cert->rsa_tmp_cb; @@ -724,7 +728,7 @@ err: #ifndef OPENSSL_SYS_WIN32 #ifndef OPENSSL_SYS_VMS /* XXXX This may be fixed in the future */ -#ifndef MAC_OS_pre_X +#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! */ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, const char *dir) @@ -771,4 +775,52 @@ err: #endif #endif + +#else + +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, + const char *dir) + { + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + int ret = 0; + + CRYPTO_w_lock(CRYPTO_LOCK_READDIR); + + hFind = FindFirstFile(dir, &FindFileData); + /* Note that a side effect is that the CAs will be sorted by name */ + if(hFind == INVALID_HANDLE_VALUE) + { + SYSerr(SYS_F_OPENDIR, get_last_sys_error()); + ERR_add_error_data(3, "opendir('", dir, "')"); + SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB); + goto err; + } + + do + { + char buf[1024]; + int r; + + if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) + { + SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); + goto err; + } + + r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,FindFileData.cFileName); + if (r <= 0 || r >= sizeof buf) + goto err; + if(!SSL_add_file_cert_subjects_to_stack(stack,buf)) + goto err; + } + while (FindNextFile(hFind, &FindFileData) != FALSE); + FindClose(hFind); + ret = 1; + +err: + CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); + return ret; + } + #endif