From: Ralf S. Engelschall Date: Sat, 5 May 2001 20:11:04 +0000 (+0000) Subject: Port ssl_util_ssl.[ch] stuff to APR. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90588a664b5eed57f180eafd449f8a82f16b1915;p=thirdparty%2Fapache%2Fhttpd.git Port ssl_util_ssl.[ch] stuff to APR. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/ssl@89029 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/README b/README index c32ba52994b..a7a63b1b53c 100644 --- a/README +++ b/README @@ -52,8 +52,8 @@ - ssl_scache_shmcb.c ...... session cache via shared memory cyclic buffer - ssl_scache_shmht.c ...... session cache via shared memory hash table - ssl_util.c .............. utility functions - - ssl_util_ssl.c .......... the OpenSSL companion source - - ssl_util_ssl.h .......... the OpenSSL companion header + # ssl_util_ssl.c .......... the OpenSSL companion source + # ssl_util_ssl.h .......... the OpenSSL companion header - ssl_util_table.c ........ the hash table library source - ssl_util_table.h ........ the hash table library header diff --git a/mod_ssl.h b/mod_ssl.h index 71b1506ecec..224ed634528 100644 --- a/mod_ssl.h +++ b/mod_ssl.h @@ -129,6 +129,7 @@ #include "apr_strings.h" #include "apr_pools.h" #include "apr_tables.h" +#include "apr_file_info.h" #undef CORE_PRIVATE /* mod_ssl headers */ diff --git a/ssl_util_ssl.c b/ssl_util_ssl.c index 4ab5e4a9920..b5bd118192b 100644 --- a/ssl_util_ssl.c +++ b/ssl_util_ssl.c @@ -59,8 +59,6 @@ #include "mod_ssl.h" -#if 0 /* XXX */ - /* _________________________________________________________________ ** ** Additional High-Level Functions for OpenSSL @@ -269,7 +267,7 @@ int SSL_X509_STORE_lookup(X509_STORE *pStore, int nType, ** _________________________________________________________________ */ -char *SSL_make_ciphersuite(pool *p, SSL *ssl) +char *SSL_make_ciphersuite(apr_pool_t *p, SSL *ssl) { STACK_OF(SSL_CIPHER) *sk; SSL_CIPHER *c; @@ -289,7 +287,7 @@ char *SSL_make_ciphersuite(pool *p, SSL *ssl) } if (l == 0) return ""; - cpCipherSuite = (char *)ap_palloc(p, l+1); + cpCipherSuite = (char *)apr_palloc(p, l+1); cp = cpCipherSuite; for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) { c = sk_SSL_CIPHER_value(sk, i); @@ -369,7 +367,7 @@ BOOL SSL_X509_getBC(X509 *cert, int *ca, int *pathlen) } /* retrieve subject CommonName of certificate */ -BOOL SSL_X509_getCN(pool *p, X509 *xs, char **cppCN) +BOOL SSL_X509_getCN(apr_pool_t *p, X509 *xs, char **cppCN) { X509_NAME *xsn; X509_NAME_ENTRY *xsne; @@ -380,8 +378,8 @@ BOOL SSL_X509_getCN(pool *p, X509 *xs, char **cppCN) xsne = sk_X509_NAME_ENTRY_value(xsn->entries, i); nid = OBJ_obj2nid(xsne->object); if (nid == NID_commonName) { - *cppCN = ap_palloc(p, xsne->value->length+1); - ap_cpystrn(*cppCN, (char *)xsne->value->data, xsne->value->length+1); + *cppCN = apr_palloc(p, xsne->value->length+1); + apr_cpystrn(*cppCN, (char *)xsne->value->data, xsne->value->length+1); (*cppCN)[xsne->value->length] = NUL; #ifdef CHARSET_EBCDIC ascii2ebcdic(*cppCN, *cppCN, strlen(*cppCN)); @@ -400,7 +398,7 @@ BOOL SSL_X509_getCN(pool *p, X509 *xs, char **cppCN) #ifdef SSL_EXPERIMENTAL_PROXY -BOOL SSL_load_CrtAndKeyInfo_file(pool *p, STACK_OF(X509_INFO) *sk, char *filename) +BOOL SSL_load_CrtAndKeyInfo_file(apr_pool_t *p, STACK_OF(X509_INFO) *sk, char *filename) { BIO *in; @@ -420,32 +418,29 @@ BOOL SSL_load_CrtAndKeyInfo_file(pool *p, STACK_OF(X509_INFO) *sk, char *filenam return TRUE; } -BOOL SSL_load_CrtAndKeyInfo_path(pool *p, STACK_OF(X509_INFO) *sk, char *pathname) +BOOL SSL_load_CrtAndKeyInfo_path(apr_pool_t *p, STACK_OF(X509_INFO) *sk, char *pathname) { - struct stat st; - DIR *dir; - pool *sp; - struct dirent *nextent; + apr_pool_t *sp; + apr_dir_t *dir; + apr_finfo_t dirent; char *fullname; BOOL ok; - sp = ap_make_sub_pool(p); - if ((dir = ap_popendir(sp, pathname)) == NULL) { - ap_destroy_pool(sp); + sp = apr_pool_sub_make(p, NULL); + if (apr_dir_open(&dir, pathname, sp)) != APR_SUCCESS) { + apr_pool_destroy(sp); return FALSE; } ok = FALSE; - while ((nextent = readdir(dir)) != NULL) { - fullname = ap_pstrcat(sp, pathname, "/", nextent->d_name, NULL); - if (stat(fullname, &st) != 0) - continue; - if (!S_ISREG(st.st_mode)) + while ((apr_dir_read(&dirent, APR_FINFO_DIRENT, dir)) == APR_SUCCESS) { + fullname = apr_pstrcat(sp, pathname, "/", dirent.name, NULL); + if (dirent.filetype != APR_REG) continue; if (SSL_load_CrtAndKeyInfo_file(sp, sk, fullname)) ok = TRUE; } - ap_pclosedir(p, dir); - ap_destroy_pool(sp); + apr_dir_close(dir); + apr_pool_destroy(sp); return ok; } @@ -534,12 +529,10 @@ char *SSL_SESSION_id2sz(unsigned char *id, int idlen) cp = str; for (n = 0; n < idlen && n < SSL_MAX_SSL_SESSION_ID_LENGTH; n++) { - ap_snprintf(cp, sizeof(str)-(cp-str), "%02X", id[n]); + apr_snprintf(cp, sizeof(str)-(cp-str), "%02X", id[n]); cp += 2; } *cp = NUL; return str; } -#endif /* XXX */ - diff --git a/ssl_util_ssl.h b/ssl_util_ssl.h index a67d8de180b..c70584339a7 100644 --- a/ssl_util_ssl.h +++ b/ssl_util_ssl.h @@ -73,8 +73,6 @@ #define SSL_LIBRARY_TEXT "OtherSSL 0.0.0 00 XXX 0000" #endif -#if 0 /* XXX */ - /* * Support for retrieving/overriding states */ @@ -101,17 +99,15 @@ EVP_PKEY *SSL_read_PrivateKey(FILE *, EVP_PKEY **, int (*)()); int SSL_smart_shutdown(SSL *ssl); X509_STORE *SSL_X509_STORE_create(char *, char *); int SSL_X509_STORE_lookup(X509_STORE *, int, X509_NAME *, X509_OBJECT *); -char *SSL_make_ciphersuite(pool *, SSL *); +char *SSL_make_ciphersuite(apr_pool_t *, SSL *); BOOL SSL_X509_isSGC(X509 *); BOOL SSL_X509_getBC(X509 *, int *, int *); -BOOL SSL_X509_getCN(pool *, X509 *, char **); +BOOL SSL_X509_getCN(apr_pool_t *, X509 *, char **); #ifdef SSL_EXPERIMENTAL_PROXY -BOOL SSL_load_CrtAndKeyInfo_file(pool *, STACK_OF(X509_INFO) *, char *); -BOOL SSL_load_CrtAndKeyInfo_path(pool *, STACK_OF(X509_INFO) *, char *); +BOOL SSL_load_CrtAndKeyInfo_file(apr_pool_t *, STACK_OF(X509_INFO) *, char *); +BOOL SSL_load_CrtAndKeyInfo_path(apr_pool_t *, STACK_OF(X509_INFO) *, char *); #endif /* SSL_EXPERIMENTAL_PROXY */ int SSL_CTX_use_certificate_chain(SSL_CTX *, char *, int, int (*)()); char *SSL_SESSION_id2sz(unsigned char *, int); -#endif /* XXX */ - #endif /* __SSL_UTIL_SSL_H__ */