Changeset 5087
- Timestamp:
- May 7, 2015 4:48:19 AM (10 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/ssl_sock.h
r5078 r5087 186 186 187 187 /** 188 * Create credential from files. 188 * Create credential from files. TLS server application can provide multiple 189 * certificates (RSA, ECC, and DSA) by supplying certificate name with "_rsa" 190 * suffix, e.g: "pjsip_rsa.pem", the library will automatically check for 191 * other certificates with "_ecc" and "_dsa" suffix. 189 192 * 190 193 * @param CA_file The file of trusted CA list. … … 204 207 205 208 /** 206 * Create credential from files. 209 * Create credential from files. TLS server application can provide multiple 210 * certificates (RSA, ECC, and DSA) by supplying certificate name with "_rsa" 211 * suffix, e.g: "pjsip_rsa.pem", the library will automatically check for 212 * other certificates with "_ecc" and "_dsa" suffix. 207 213 * 208 214 * This is the same as pj_ssl_cert_load_from_files() but also -
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5083 r5087 22 22 #include <pj/assert.h> 23 23 #include <pj/errno.h> 24 #include <pj/file_access.h> 24 25 #include <pj/list.h> 25 26 #include <pj/lock.h> … … 672 673 673 674 if (ssock->is_server) { 675 char *p = NULL; 676 677 /* If certificate file name contains "_rsa.", let's check if there are 678 * ecc and dsa certificates too. 679 */ 680 if (cert && cert->cert_file.slen) { 681 const pj_str_t RSA = {"_rsa.", 5}; 682 p = pj_strstr(&cert->cert_file, &RSA); 683 if (p) p++; /* Skip underscore */ 684 } 685 if (p) { 686 /* Certificate type string length must be exactly 3 */ 687 enum { CERT_TYPE_LEN = 3 }; 688 const char* cert_types[] = { "ecc", "dsa" }; 689 char *cf = cert->cert_file.ptr; 690 int i; 691 692 /* Check and load ECC & DSA certificates & private keys */ 693 for (i = 0; i < PJ_ARRAY_SIZE(cert_types); ++i) { 694 int err; 695 696 pj_memcpy(p, cert_types[i], CERT_TYPE_LEN); 697 if (!pj_file_exists(cf)) 698 continue; 699 700 err = SSL_CTX_use_certificate_chain_file(ctx, cf); 701 if (err == 1) 702 err = SSL_CTX_use_PrivateKey_file(ctx, cf, 703 SSL_FILETYPE_PEM); 704 if (err == 1) { 705 PJ_LOG(4,(ssock->pool->obj_name, 706 "Additional certificate '%s' loaded.", cf)); 707 } else { 708 pj_perror(1, ssock->pool->obj_name, GET_SSL_STATUS(ssock), 709 "Error loading certificate file '%s'", cf); 710 ERR_clear_error(); 711 } 712 } 713 714 /* Put back original name */ 715 pj_memcpy(p, "rsa", CERT_TYPE_LEN); 716 } 717 674 718 #ifndef SSL_CTRL_SET_ECDH_AUTO 675 719 #define SSL_CTRL_SET_ECDH_AUTO 94
Note: See TracChangeset
for help on using the changeset viewer.