Changeset 4973 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Jan 15, 2015 6:55:02 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r4972 r4973 190 190 { 191 191 pj_str_t CA_file; 192 pj_str_t CA_path; 192 193 pj_str_t cert_file; 193 194 pj_str_t privkey_file; … … 582 583 if (cert) { 583 584 /* Load CA list if one is specified. */ 584 if (cert->CA_file.slen) { 585 586 rc = SSL_CTX_load_verify_locations(ctx, cert->CA_file.ptr, NULL); 585 if (cert->CA_file.slen || cert->CA_path.slen) { 586 587 rc = SSL_CTX_load_verify_locations( 588 ctx, 589 cert->CA_file.slen == 0 ? NULL : cert->CA_file.ptr, 590 cert->CA_path.slen == 0 ? NULL : cert->CA_path.ptr); 587 591 588 592 if (rc != 1) { 589 593 status = GET_SSL_STATUS(ssock); 590 PJ_LOG(1,(ssock->pool->obj_name, "Error loading CA list file " 591 "'%s'", cert->CA_file.ptr)); 594 if (cert->CA_file.slen) { 595 PJ_LOG(1,(ssock->pool->obj_name, 596 "Error loading CA list file '%s'", 597 cert->CA_file.ptr)); 598 } 599 if (cert->CA_path.slen) { 600 PJ_LOG(1,(ssock->pool->obj_name, 601 "Error loading CA path '%s'", 602 cert->CA_path.ptr)); 603 } 592 604 SSL_CTX_free(ctx); 593 605 return status; … … 1929 1941 pj_ssl_cert_t **p_cert) 1930 1942 { 1943 return pj_ssl_cert_load_from_files2(pool, CA_file, NULL, cert_file, 1944 privkey_file, privkey_pass, p_cert); 1945 } 1946 1947 PJ_DEF(pj_status_t) pj_ssl_cert_load_from_files2(pj_pool_t *pool, 1948 const pj_str_t *CA_file, 1949 const pj_str_t *CA_path, 1950 const pj_str_t *cert_file, 1951 const pj_str_t *privkey_file, 1952 const pj_str_t *privkey_pass, 1953 pj_ssl_cert_t **p_cert) 1954 { 1931 1955 pj_ssl_cert_t *cert; 1932 1956 1933 PJ_ASSERT_RETURN(pool && CA_file && cert_file && privkey_file, PJ_EINVAL); 1957 PJ_ASSERT_RETURN(pool && (CA_file || CA_path) && cert_file && 1958 privkey_file, 1959 PJ_EINVAL); 1934 1960 1935 1961 cert = PJ_POOL_ZALLOC_T(pool, pj_ssl_cert_t); 1936 pj_strdup_with_null(pool, &cert->CA_file, CA_file); 1962 if (CA_file) { 1963 pj_strdup_with_null(pool, &cert->CA_file, CA_file); 1964 } 1965 if (CA_path) { 1966 pj_strdup_with_null(pool, &cert->CA_path, CA_path); 1967 } 1937 1968 pj_strdup_with_null(pool, &cert->cert_file, cert_file); 1938 1969 pj_strdup_with_null(pool, &cert->privkey_file, privkey_file); … … 1958 1989 pj_memcpy(cert_, cert, sizeof(cert)); 1959 1990 pj_strdup_with_null(pool, &cert_->CA_file, &cert->CA_file); 1991 pj_strdup_with_null(pool, &cert_->CA_path, &cert->CA_path); 1960 1992 pj_strdup_with_null(pool, &cert_->cert_file, &cert->cert_file); 1961 1993 pj_strdup_with_null(pool, &cert_->privkey_file, &cert->privkey_file);
Note: See TracChangeset
for help on using the changeset viewer.