Changeset 4973
- Timestamp:
- Jan 15, 2015 6:55:02 AM (10 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/ssl_sock.h
r4968 r4973 202 202 const pj_str_t *privkey_pass, 203 203 pj_ssl_cert_t **p_cert); 204 205 /** 206 * Create credential from files. 207 * 208 * This is the same as pj_ssl_cert_load_from_files() but also 209 * accepts an additional param CA_path to load CA certificates from 210 * a directory. 211 * 212 * @param CA_file The file of trusted CA list. 213 * @param CA_path The path to a directory of trusted CA list. 214 * @param cert_file The file of certificate. 215 * @param privkey_file The file of private key. 216 * @param privkey_pass The password of private key, if any. 217 * @param p_cert Pointer to credential instance to be created. 218 * 219 * @return PJ_SUCCESS when successful. 220 */ 221 PJ_DECL(pj_status_t) pj_ssl_cert_load_from_files2( 222 pj_pool_t *pool, 223 const pj_str_t *CA_file, 224 const pj_str_t *CA_path, 225 const pj_str_t *cert_file, 226 const pj_str_t *privkey_file, 227 const pj_str_t *privkey_pass, 228 pj_ssl_cert_t **p_cert); 204 229 205 230 -
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); -
pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp
r4968 r4973 860 860 pj_ssl_cert_t **p_cert) 861 861 { 862 return pj_ssl_cert_load_from_files2(pool, CA_file, NULL, cert_file, 863 privkey_file, privkey_pass, p_cert); 864 } 865 866 PJ_DEF(pj_status_t) pj_ssl_cert_load_from_files2(pj_pool_t *pool, 867 const pj_str_t *CA_file, 868 const pj_str_t *CA_path, 869 const pj_str_t *cert_file, 870 const pj_str_t *privkey_file, 871 const pj_str_t *privkey_pass, 872 pj_ssl_cert_t **p_cert) 873 { 862 874 PJ_UNUSED_ARG(pool); 863 875 PJ_UNUSED_ARG(CA_file); 876 PJ_UNUSED_ARG(CA_path); 864 877 PJ_UNUSED_ARG(cert_file); 865 878 PJ_UNUSED_ARG(privkey_file); -
pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h
r4968 r4973 84 84 */ 85 85 pj_str_t ca_list_file; 86 87 /** 88 * Certificate of Authority (CA) list directory path. 89 */ 90 pj_str_t ca_list_path; 86 91 87 92 /** -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r4968 r4973 442 442 /* Check if certificate/CA list for SSL socket is set */ 443 443 if (listener->tls_setting.cert_file.slen || 444 listener->tls_setting.ca_list_file.slen) 444 listener->tls_setting.ca_list_file.slen || 445 listener->tls_setting.ca_list_path.slen) 445 446 { 446 status = pj_ssl_cert_load_from_files (pool,447 status = pj_ssl_cert_load_from_files2(pool, 447 448 &listener->tls_setting.ca_list_file, 449 &listener->tls_setting.ca_list_path, 448 450 &listener->tls_setting.cert_file, 449 451 &listener->tls_setting.privkey_file,
Note: See TracChangeset
for help on using the changeset viewer.