- Timestamp:
- Oct 16, 2009 3:06:13 AM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/ssl_sock.h
r2913 r2950 46 46 */ 47 47 48 /** 49 * Opaque declaration of certificate or endpoint credentials. This may contains 50 * certificate, private key, and trusted Certificate Authorities lists. 48 49 /** 50 * This opaque structure describes the secure socket. 51 */ 52 typedef struct pj_ssl_sock_t pj_ssl_sock_t; 53 54 55 /** 56 * Opaque declaration of endpoint certificate or credentials. This may contains 57 * certificate, private key, and trusted Certificate Authorities list. 51 58 */ 52 59 typedef struct pj_ssl_cert_t pj_ssl_cert_t; 53 60 54 /** 55 * This opaque structure describes the secure socket. 56 */ 57 typedef struct pj_ssl_sock_t pj_ssl_sock_t; 61 62 /** 63 * Create credential from files. 64 * 65 * @param CA_file The file of trusted CA list. 66 * @param cert_file The file of certificate. 67 * @param privkey_file The file of private key. 68 * @param privkey_pass The password of private key, if any. 69 * 70 * @return PJ_SUCCESS when successful. 71 */ 72 PJ_DECL(pj_status_t) pj_ssl_cert_load_from_files(pj_pool_t *pool, 73 const pj_str_t *CA_file, 74 const pj_str_t *cert_file, 75 const pj_str_t *privkey_file, 76 const pj_str_t *privkey_pass, 77 pj_ssl_cert_t **p_cert); 78 79 80 /** 81 * Cipher suites enumeration. 82 */ 83 typedef enum pj_ssl_cipher { 84 85 /* NULL */ 86 TLS_NULL_WITH_NULL_NULL = 0x00000000, 87 88 /* TLS/SSLv3 */ 89 TLS_RSA_WITH_NULL_MD5 = 0x00000001, 90 TLS_RSA_WITH_NULL_SHA = 0x00000002, 91 TLS_RSA_WITH_NULL_SHA256 = 0x0000003B, 92 TLS_RSA_WITH_RC4_128_MD5 = 0x00000004, 93 TLS_RSA_WITH_RC4_128_SHA = 0x00000005, 94 TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0000000A, 95 TLS_RSA_WITH_AES_128_CBC_SHA = 0x0000002F, 96 TLS_RSA_WITH_AES_256_CBC_SHA = 0x00000035, 97 TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003C, 98 TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x0000003D, 99 TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0000000D, 100 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000010, 101 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x00000013, 102 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000016, 103 TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x00000030, 104 TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x00000031, 105 TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x00000032, 106 TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x00000033, 107 TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x00000036, 108 TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x00000037, 109 TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x00000038, 110 TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x00000039, 111 TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x0000003E, 112 TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003F, 113 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x00000040, 114 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x00000067, 115 TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x00000068, 116 TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x00000069, 117 TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x0000006A, 118 TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x0000006B, 119 TLS_DH_anon_WITH_RC4_128_MD5 = 0x00000018, 120 TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x0000001B, 121 TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x00000034, 122 TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x0000003A, 123 TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x0000006C, 124 TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x0000006D, 125 126 /* TLS (deprecated) */ 127 TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x00000003, 128 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x00000006, 129 TLS_RSA_WITH_IDEA_CBC_SHA = 0x00000007, 130 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000008, 131 TLS_RSA_WITH_DES_CBC_SHA = 0x00000009, 132 TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0000000B, 133 TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0000000C, 134 TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0000000E, 135 TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0000000F, 136 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x00000011, 137 TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x00000012, 138 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000014, 139 TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x00000015, 140 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x00000017, 141 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x00000019, 142 TLS_DH_anon_WITH_DES_CBC_SHA = 0x0000001A, 143 144 /* SSLv3 */ 145 SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x0000001C, 146 SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA= 0x0000001D, 147 SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x0000001E, 148 149 /* SSLv2 */ 150 SSL_CK_RC4_128_WITH_MD5 = 0x00010080, 151 SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x00020080, 152 SSL_CK_RC2_128_CBC_WITH_MD5 = 0x00030080, 153 SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x00040080, 154 SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x00050080, 155 SSL_CK_DES_64_CBC_WITH_MD5 = 0x00060040, 156 SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x000700C0 157 158 } pj_ssl_cipher; 159 160 161 /** 162 * Get cipher list supported by SSL/TLS backend. 163 * 164 * @param ciphers The ciphers buffer to receive cipher list. 165 * @param cipher_num Maximum number of ciphers to be received. 166 * 167 * @return PJ_SUCCESS when successful. 168 */ 169 PJ_DECL(pj_status_t) pj_ssl_cipher_get_availables(pj_ssl_cipher ciphers[], 170 unsigned *cipher_num); 171 172 173 /** 174 * Get cipher name string. 175 * 176 * @param cipher The cipher. 177 * 178 * @return The cipher name or NULL if cipher is not recognized. 179 */ 180 PJ_DECL(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher); 181 58 182 59 183 /** … … 181 305 PJ_SSL_SOCK_PROTO_DEFAULT, /**< Default protocol of backend. */ 182 306 PJ_SSL_SOCK_PROTO_TLS1, /**< TLSv1.0 protocol. */ 183 PJ_SSL_SOCK_PROTO_SSL2, /**< SSLv2.0 protocol. */184 307 PJ_SSL_SOCK_PROTO_SSL3, /**< SSLv3.0 protocol. */ 185 308 PJ_SSL_SOCK_PROTO_SSL23, /**< SSLv3.0 but can roll back to 186 309 SSLv2.0. */ 310 PJ_SSL_SOCK_PROTO_SSL2, /**< SSLv2.0 protocol. */ 187 311 PJ_SSL_SOCK_PROTO_DTLS1 /**< DTLSv1.0 protocol. */ 188 312 } pj_ssl_sock_proto; … … 204 328 pj_ssl_sock_proto proto; 205 329 /** 206 * Describes cipher suite being used, this can be known only when207 * connectionis established.208 */ 209 pj_s tr_tcipher;330 * Describes cipher suite being used, this will only be set when connection 331 * is established. 332 */ 333 pj_ssl_cipher cipher; 210 334 /** 211 335 * Describes local address. … … 218 342 219 343 } pj_ssl_sock_info; 344 220 345 221 346 /** … … 317 442 318 443 /** 319 * Cipher list string. If empty, then default cipher list of the backend 444 * Specify buffer size for receiving encrypted (and perhaps compressed) 445 * data on underlying socket. This setting is unused on Symbian, since 446 * SSL/TLS Symbian backend, CSecureSocket, can use application buffer 447 * directly. 448 * 449 * Default value is 1500. 450 */ 451 pj_size_t read_buffer_size; 452 453 /** 454 * Number of ciphers contained in the specified cipher preference. 455 * If this is set to zero, then default cipher list of the backend 320 456 * will be used. 321 457 */ 322 pj_str_t ciphers; 458 unsigned ciphers_num; 459 460 /** 461 * Ciphers and order preference. If empty, then default cipher list and 462 * its default order of the backend will be used. 463 */ 464 pj_ssl_cipher *ciphers; 323 465 324 466 /** -
pjproject/trunk/pjlib/src/pj/ssl_sock_common.c
r2913 r2950 18 18 */ 19 19 #include <pj/ssl_sock.h> 20 #include <pj/errno.h> 20 21 #include <pj/string.h> 22 23 /* Cipher name structure */ 24 typedef struct cipher_name_t { 25 pj_ssl_cipher cipher; 26 const char *name; 27 } cipher_name_t; 28 29 /* Cipher name constants */ 30 static cipher_name_t cipher_names[] = 31 { 32 {TLS_NULL_WITH_NULL_NULL, "NULL"}, 33 34 /* TLS/SSLv3 */ 35 {TLS_RSA_WITH_NULL_MD5, "TLS_RSA_WITH_NULL_MD5"}, 36 {TLS_RSA_WITH_NULL_SHA, "TLS_RSA_WITH_NULL_SHA"}, 37 {TLS_RSA_WITH_NULL_SHA256, "TLS_RSA_WITH_NULL_SHA256"}, 38 {TLS_RSA_WITH_RC4_128_MD5, "TLS_RSA_WITH_RC4_128_MD5"}, 39 {TLS_RSA_WITH_RC4_128_SHA, "TLS_RSA_WITH_RC4_128_SHA"}, 40 {TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_RSA_WITH_3DES_EDE_CBC_SHA"}, 41 {TLS_RSA_WITH_AES_128_CBC_SHA, "TLS_RSA_WITH_AES_128_CBC_SHA"}, 42 {TLS_RSA_WITH_AES_256_CBC_SHA, "TLS_RSA_WITH_AES_256_CBC_SHA"}, 43 {TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS_RSA_WITH_AES_128_CBC_SHA256"}, 44 {TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS_RSA_WITH_AES_256_CBC_SHA256"}, 45 {TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA"}, 46 {TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA"}, 47 {TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"}, 48 {TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA"}, 49 {TLS_DH_DSS_WITH_AES_128_CBC_SHA, "TLS_DH_DSS_WITH_AES_128_CBC_SHA"}, 50 {TLS_DH_RSA_WITH_AES_128_CBC_SHA, "TLS_DH_RSA_WITH_AES_128_CBC_SHA"}, 51 {TLS_DHE_DSS_WITH_AES_128_CBC_SHA, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"}, 52 {TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA"}, 53 {TLS_DH_DSS_WITH_AES_256_CBC_SHA, "TLS_DH_DSS_WITH_AES_256_CBC_SHA"}, 54 {TLS_DH_RSA_WITH_AES_256_CBC_SHA, "TLS_DH_RSA_WITH_AES_256_CBC_SHA"}, 55 {TLS_DHE_DSS_WITH_AES_256_CBC_SHA, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA"}, 56 {TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"}, 57 {TLS_DH_DSS_WITH_AES_128_CBC_SHA256, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256"}, 58 {TLS_DH_RSA_WITH_AES_128_CBC_SHA256, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256"}, 59 {TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"}, 60 {TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"}, 61 {TLS_DH_DSS_WITH_AES_256_CBC_SHA256, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256"}, 62 {TLS_DH_RSA_WITH_AES_256_CBC_SHA256, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256"}, 63 {TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"}, 64 {TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"}, 65 {TLS_DH_anon_WITH_RC4_128_MD5, "TLS_DH_anon_WITH_RC4_128_MD5"}, 66 {TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"}, 67 {TLS_DH_anon_WITH_AES_128_CBC_SHA, "TLS_DH_anon_WITH_AES_128_CBC_SHA"}, 68 {TLS_DH_anon_WITH_AES_256_CBC_SHA, "TLS_DH_anon_WITH_AES_256_CBC_SHA"}, 69 {TLS_DH_anon_WITH_AES_128_CBC_SHA256, "TLS_DH_anon_WITH_AES_128_CBC_SHA256"}, 70 {TLS_DH_anon_WITH_AES_256_CBC_SHA256, "TLS_DH_anon_WITH_AES_256_CBC_SHA256"}, 71 72 /* TLS (deprecated) */ 73 {TLS_RSA_EXPORT_WITH_RC4_40_MD5, "TLS_RSA_EXPORT_WITH_RC4_40_MD5"}, 74 {TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5"}, 75 {TLS_RSA_WITH_IDEA_CBC_SHA, "TLS_RSA_WITH_IDEA_CBC_SHA"}, 76 {TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 77 {TLS_RSA_WITH_DES_CBC_SHA, "TLS_RSA_WITH_DES_CBC_SHA"}, 78 {TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA"}, 79 {TLS_DH_DSS_WITH_DES_CBC_SHA, "TLS_DH_DSS_WITH_DES_CBC_SHA"}, 80 {TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 81 {TLS_DH_RSA_WITH_DES_CBC_SHA, "TLS_DH_RSA_WITH_DES_CBC_SHA"}, 82 {TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"}, 83 {TLS_DHE_DSS_WITH_DES_CBC_SHA, "TLS_DHE_DSS_WITH_DES_CBC_SHA"}, 84 {TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"}, 85 {TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS_DHE_RSA_WITH_DES_CBC_SHA"}, 86 {TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5"}, 87 {TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA"}, 88 {TLS_DH_anon_WITH_DES_CBC_SHA, "TLS_DH_anon_WITH_DES_CBC_SHA"}, 89 90 /* SSLv3 */ 91 {SSL_FORTEZZA_KEA_WITH_NULL_SHA, "SSL_FORTEZZA_KEA_WITH_NULL_SHA"}, 92 {SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA,"SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"}, 93 {SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"}, 94 95 /* SSLv2 */ 96 {SSL_CK_RC4_128_WITH_MD5, "SSL_CK_RC4_128_WITH_MD5"}, 97 {SSL_CK_RC4_128_EXPORT40_WITH_MD5, "SSL_CK_RC4_128_EXPORT40_WITH_MD5"}, 98 {SSL_CK_RC2_128_CBC_WITH_MD5, "SSL_CK_RC2_128_CBC_WITH_MD5"}, 99 {SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5, "SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5"}, 100 {SSL_CK_IDEA_128_CBC_WITH_MD5, "SSL_CK_IDEA_128_CBC_WITH_MD5"}, 101 {SSL_CK_DES_64_CBC_WITH_MD5, "SSL_CK_DES_64_CBC_WITH_MD5"}, 102 {SSL_CK_DES_192_EDE3_CBC_WITH_MD5, "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"} 103 }; 104 21 105 22 106 /* 23 107 * Initialize the SSL socket configuration with the default values. 24 108 */ 25 PJ_DE CL(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param)109 PJ_DEF(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param) 26 110 { 27 111 pj_bzero(param, sizeof(*param)); … … 33 117 param->concurrency = -1; 34 118 param->whole_data = PJ_TRUE; 35 #if PJ_SYMBIAN36 119 param->send_buffer_size = 8192; 120 #if !defined(PJ_SYMBIAN) || PJ_SYMBIAN==0 121 param->read_buffer_size = 1500; 37 122 #endif 38 123 … … 42 127 43 128 129 PJ_DEF(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher) 130 { 131 unsigned i, n; 132 133 n = PJ_ARRAY_SIZE(cipher_names); 134 for (i = 0; i < n; ++i) { 135 if (cipher == cipher_names[i].cipher) 136 return cipher_names[i].name; 137 } 138 139 return NULL; 140 } -
pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp
r2913 r2950 21 21 #include <pj/assert.h> 22 22 #include <pj/errno.h> 23 #include <pj/math.h> 23 24 #include <pj/pool.h> 24 25 #include <pj/sock.h> … … 414 415 pj_ssl_sock_proto proto; 415 416 pj_time_val timeout; 416 pj_str_t ciphers; 417 unsigned ciphers_num; 418 pj_ssl_cipher *ciphers; 417 419 pj_str_t servername; 418 420 }; 419 421 422 423 /* 424 * Get cipher list supported by SSL/TLS backend. 425 */ 426 PJ_DEF(pj_status_t) pj_ssl_cipher_get_availables (pj_ssl_cipher ciphers[], 427 unsigned *cipher_num) 428 { 429 /* Available ciphers */ 430 static pj_ssl_cipher ciphers_[64]; 431 static unsigned ciphers_num_ = 0; 432 unsigned i; 433 434 PJ_ASSERT_RETURN(ciphers && cipher_num, PJ_EINVAL); 435 436 if (ciphers_num_ == 0) { 437 RSocket sock; 438 CSecureSocket *secure_sock; 439 TPtrC16 proto(_L16("TLS1.0")); 440 441 secure_sock = CSecureSocket::NewL(sock, proto); 442 if (secure_sock) { 443 TBuf8<128> ciphers_buf(0); 444 secure_sock->AvailableCipherSuites(ciphers_buf); 445 446 ciphers_num_ = ciphers_buf.Length() / 2; 447 if (ciphers_num_ > PJ_ARRAY_SIZE(ciphers_)) 448 ciphers_num_ = PJ_ARRAY_SIZE(ciphers_); 449 for (i = 0; i < ciphers_num_; ++i) 450 ciphers_[i] = (pj_ssl_cipher)ciphers_buf[i*2]; 451 } 452 453 delete secure_sock; 454 } 455 456 if (ciphers_num_ == 0) { 457 return PJ_ENOTFOUND; 458 } 459 460 *cipher_num = PJ_MIN(*cipher_num, ciphers_num_); 461 for (i = 0; i < *cipher_num; ++i) 462 ciphers[i] = ciphers_[i]; 463 464 return PJ_SUCCESS; 465 } 420 466 421 467 /* … … 445 491 ssock->cb = param->cb; 446 492 ssock->user_data = param->user_data; 447 pj_strdup_with_null(pool, &ssock->ciphers, ¶m->ciphers); 493 ssock->ciphers_num = param->ciphers_num; 494 if (param->ciphers_num > 0) { 495 unsigned i; 496 ssock->ciphers = (pj_ssl_cipher*) 497 pj_pool_calloc(pool, param->ciphers_num, 498 sizeof(pj_ssl_cipher)); 499 for (i = 0; i < param->ciphers_num; ++i) 500 ssock->ciphers[i] = param->ciphers[i]; 501 } 448 502 pj_strdup_with_null(pool, &ssock->servername, ¶m->servername); 449 503 … … 452 506 453 507 return PJ_SUCCESS; 508 } 509 510 511 PJ_DEF(pj_status_t) pj_ssl_cert_load_from_files(pj_pool_t *pool, 512 const pj_str_t *CA_file, 513 const pj_str_t *cert_file, 514 const pj_str_t *privkey_file, 515 const pj_str_t *privkey_pass, 516 pj_ssl_cert_t **p_cert) 517 { 518 PJ_UNUSED_ARG(pool); 519 PJ_UNUSED_ARG(CA_file); 520 PJ_UNUSED_ARG(cert_file); 521 PJ_UNUSED_ARG(privkey_file); 522 PJ_UNUSED_ARG(privkey_pass); 523 PJ_UNUSED_ARG(p_cert); 524 return PJ_ENOTSUP; 454 525 } 455 526 … … 522 593 pj_ssl_sock_info *info) 523 594 { 524 const char *cipher_names[0x1B] = {525 "TLS_RSA_WITH_NULL_MD5",526 "TLS_RSA_WITH_NULL_SHA",527 "TLS_RSA_EXPORT_WITH_RC4_40_MD5",528 "TLS_RSA_WITH_RC4_128_MD5",529 "TLS_RSA_WITH_RC4_128_SHA",530 "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5",531 "TLS_RSA_WITH_IDEA_CBC_SHA",532 "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",533 "TLS_RSA_WITH_DES_CBC_SHA",534 "TLS_RSA_WITH_3DES_EDE_CBC_SHA",535 "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA",536 "TLS_DH_DSS_WITH_DES_CBC_SHA",537 "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA",538 "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA",539 "TLS_DH_RSA_WITH_DES_CBC_SHA",540 "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA",541 "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",542 "TLS_DHE_DSS_WITH_DES_CBC_SHA",543 "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA",544 "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",545 "TLS_DHE_RSA_WITH_DES_CBC_SHA",546 "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",547 "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5",548 "TLS_DH_anon_WITH_RC4_128_MD5",549 "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA",550 "TLS_DH_anon_WITH_DES_CBC_SHA",551 "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"552 };553 554 595 PJ_ASSERT_RETURN(ssock && info, PJ_EINVAL); 555 596 … … 571 612 } 572 613 573 /* Remote address */574 pj_sockaddr_cp((pj_sockaddr_t*)&info->remote_addr,575 (pj_sockaddr_t*)&ssock->rem_addr);576 577 /* Cipher suite */578 614 if (info->established) { 579 TBuf8<8> cipher; 615 /* Cipher suite */ 616 TBuf8<4> cipher; 580 617 if (ssock->sock->GetCipher(cipher) == KErrNone) { 581 TLex8 lex(cipher); 582 TUint cipher_code = cipher[1]; 583 if (cipher_code>=1 && cipher_code<=0x1B) 584 info->cipher = pj_str((char*)cipher_names[cipher_code-1]); 585 } 618 info->cipher = (pj_ssl_cipher)cipher[1]; 619 } 620 621 /* Remote address */ 622 pj_sockaddr_cp((pj_sockaddr_t*)&info->remote_addr, 623 (pj_sockaddr_t*)&ssock->rem_addr); 586 624 } 587 625 -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r2913 r2950 241 241 ssock_param.cb.on_data_sent = &on_data_sent; 242 242 ssock_param.async_cnt = async_cnt; 243 ssock_param.ciphers = listener->tls_setting.ciphers;244 243 ssock_param.ioqueue = pjsip_endpt_get_ioqueue(endpt); 245 244 ssock_param.require_client_cert = listener->tls_setting.require_client_cert; … … 248 247 ssock_param.user_data = listener; 249 248 ssock_param.verify_peer = listener->tls_setting.verify_client; 249 if (ssock_param.send_buffer_size < PJSIP_MAX_PKT_LEN) 250 ssock_param.send_buffer_size = PJSIP_MAX_PKT_LEN; 251 if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN) 252 ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN; 253 254 has_listener = PJ_FALSE; 250 255 251 256 switch(listener->tls_setting.method) { … … 280 285 } 281 286 287 /* Check if certificate for SSL socket is set */ 288 if (listener->tls_setting.cert_file.slen) 289 { 290 pj_ssl_cert_t *cert; 291 292 status = pj_ssl_cert_load_from_files(pool, 293 &listener->tls_setting.ca_list_file, 294 &listener->tls_setting.cert_file, 295 &listener->tls_setting.privkey_file, 296 &listener->tls_setting.password, 297 &cert); 298 if (status != PJ_SUCCESS) 299 goto on_error; 300 301 status = pj_ssl_sock_set_certificate(listener->ssock, pool, cert); 302 if (status != PJ_SUCCESS) 303 goto on_error; 304 } 305 282 306 /* Start accepting incoming connections. Note that some TLS/SSL backends 283 307 * may not support for SSL socket server. 284 308 */ 285 309 has_listener = PJ_FALSE; 310 286 311 status = pj_ssl_sock_start_accept(listener->ssock, pool, 287 312 (pj_sockaddr_t*)listener_addr, … … 352 377 } 353 378 354 PJ_LOG(4,(listener->factory.obj_name, 355 "SIP TLS listener is ready%s at %.*s:%d", 356 (has_listener?" for incoming connections":""), 357 (int)listener->factory.addr_name.host.slen, 358 listener->factory.addr_name.host.ptr, 359 listener->factory.addr_name.port)); 379 if (has_listener) { 380 PJ_LOG(4,(listener->factory.obj_name, 381 "SIP TLS listener is ready for incoming connections " 382 "at %.*s:%d", 383 (int)listener->factory.addr_name.host.slen, 384 listener->factory.addr_name.host.ptr, 385 listener->factory.addr_name.port)); 386 } else { 387 PJ_LOG(4,(listener->factory.obj_name, "SIP TLS is ready " 388 "(client only)")); 389 } 360 390 361 391 /* Return the pointer to user */ … … 757 787 ssock_param.cb.on_data_sent = &on_data_sent; 758 788 ssock_param.async_cnt = 1; 759 ssock_param.ciphers = listener->tls_setting.ciphers;760 789 ssock_param.ioqueue = pjsip_endpt_get_ioqueue(listener->endpt); 761 PJ_TODO(SET_PROPER_SERVERNAME_BASED_ON_TARGET); 790 PJ_TODO(set_proper_servername_based_on_target); 791 PJ_TODO(synchronize_tls_cipher_type_with_ssl_sock_cipher_type); 762 792 ssock_param.servername = listener->tls_setting.server_name; 763 793 ssock_param.timeout = listener->tls_setting.timeout; 764 794 ssock_param.user_data = NULL; /* pending, must be set later */ 765 795 ssock_param.verify_peer = listener->tls_setting.verify_server; 766 796 if (ssock_param.send_buffer_size < PJSIP_MAX_PKT_LEN) 797 ssock_param.send_buffer_size = PJSIP_MAX_PKT_LEN; 798 if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN) 799 ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN; 800 767 801 switch(listener->tls_setting.method) { 768 802 case PJSIP_TLSV1_METHOD: … … 894 928 (const pj_sockaddr_in*)&listener->factory.local_addr, 895 929 (const pj_sockaddr_in*)src_addr, &tls); 930 896 931 if (status == PJ_SUCCESS) { 932 /* Set the "pending" SSL socket user data */ 933 pj_ssl_sock_set_user_data(new_ssock, tls); 934 897 935 status = tls_start_read(tls); 898 936 if (status != PJ_SUCCESS) { … … 1173 1211 tls = (struct tls_transport*) pj_ssl_sock_get_user_data(ssock); 1174 1212 1175 /* Mark that pending connect() operation has completed. */1176 tls->has_pending_connect = PJ_FALSE;1177 1178 1213 /* Check connect() status */ 1179 1214 if (status != PJ_SUCCESS) { … … 1203 1238 return PJ_FALSE; 1204 1239 } 1205 1206 PJ_LOG(4,(tls->base.obj_name,1207 "TLS transport %.*s:%d is connected to %.*s:%d",1208 (int)tls->base.local_name.host.slen,1209 tls->base.local_name.host.ptr,1210 tls->base.local_name.port,1211 (int)tls->base.remote_name.host.slen,1212 tls->base.remote_name.host.ptr,1213 tls->base.remote_name.port));1214 1215 1240 1216 1241 /* Update (again) local address, just in case local address currently … … 1234 1259 } 1235 1260 1261 PJ_LOG(4,(tls->base.obj_name, 1262 "TLS transport %.*s:%d is connected to %.*s:%d", 1263 (int)tls->base.local_name.host.slen, 1264 tls->base.local_name.host.ptr, 1265 tls->base.local_name.port, 1266 (int)tls->base.remote_name.host.slen, 1267 tls->base.remote_name.host.ptr, 1268 tls->base.remote_name.port)); 1269 1270 /* Mark that pending connect() operation has completed. */ 1271 tls->has_pending_connect = PJ_FALSE; 1272 1236 1273 /* Start pending read */ 1237 1274 status = tls_start_read(tls); … … 1262 1299 } 1263 1300 1301 1264 1302 /* Transport keep-alive timer callback */ 1265 1303 static void tls_keep_alive_timer(pj_timer_heap_t *th, pj_timer_entry *e)
Note: See TracChangeset
for help on using the changeset viewer.