- Timestamp:
- Feb 26, 2018 7:50:18 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp_dtls.c
r5635 r5746 375 375 unsigned i; 376 376 int mode, rc; 377 377 378 /* Check if it is already instantiated */ 379 if (ds->ossl_ssl) 380 return PJ_SUCCESS; 381 378 382 /* Create DTLS context */ 379 383 ctx = SSL_CTX_new(DTLS_method()); … … 685 689 pj_status_t status; 686 690 int err; 691 692 /* Init DTLS (if not yet) */ 693 status = ssl_create(ds); 694 if (status != PJ_SUCCESS) 695 return status; 687 696 688 697 /* Check if handshake has been initiated or even completed */ … … 1014 1023 } 1015 1024 1016 /* Init DTLS */1017 if (!ds->ossl_ssl) {1018 status = ssl_create(ds);1019 if (status != PJ_SUCCESS)1020 goto on_return;1021 }1022 1023 1025 /* Set remote cert fingerprint verification status to PJ_EPENDING */ 1024 1026 ds->rem_fprint_status = PJ_EPENDING; … … 1100 1102 ds->nego_started = PJ_FALSE; 1101 1103 ds->got_keys = PJ_FALSE; 1102 1103 status = ssl_create(ds); 1104 if (status != PJ_SUCCESS) 1105 goto on_return; 1106 } 1107 } 1108 1109 /* Set media transport to UDP/TLS/RTP/SAVP */ 1110 m_loc->desc.transport = ID_TP_DTLS_SRTP; 1104 ds->rem_fprint_status = PJ_EPENDING; 1105 } 1106 } 1107 1108 /* Set media transport to UDP/TLS/RTP/SAVP if we are the offerer, 1109 * otherwise just match it to the offer (currently we only accept 1110 * UDP/TLS/RTP/SAVP in remote offer though). 1111 */ 1112 if (ds->srtp->offerer_side) { 1113 m_loc->desc.transport = ID_TP_DTLS_SRTP; 1114 } else { 1115 m_loc->desc.transport = 1116 sdp_remote->media[media_index]->desc.transport; 1117 } 1111 1118 1112 1119 /* Add a=fingerprint attribute, fingerprint of our TLS certificate */ … … 1170 1177 use_ice = ice_info && ice_info->comp_cnt; 1171 1178 if (!use_ice) { 1179 /* Start SSL nego */ 1172 1180 status = ssl_handshake(ds); 1173 1181 if (status != PJ_SUCCESS) … … 1223 1231 ds->nego_started = PJ_FALSE; 1224 1232 ds->got_keys = PJ_FALSE; 1225 1226 status = ssl_create(ds); 1227 if (status != PJ_SUCCESS) 1228 goto on_return; 1233 ds->rem_fprint_status = PJ_EPENDING; 1229 1234 } 1230 1235 } else { … … 1387 1392 1388 1393 /* Find DTLS keying and destroy any other keying. */ 1389 for (j = 0; j < srtp-> keying_cnt; ++j) {1390 if (srtp-> keying[j]->op == &dtls_op)1391 ds = (dtls_srtp*)srtp-> keying[j];1394 for (j = 0; j < srtp->all_keying_cnt; ++j) { 1395 if (srtp->all_keying[j]->op == &dtls_op) 1396 ds = (dtls_srtp*)srtp->all_keying[j]; 1392 1397 else 1393 pjmedia_transport_close(srtp-> keying[j]);1398 pjmedia_transport_close(srtp->all_keying[j]); 1394 1399 } 1395 1400 … … 1401 1406 srtp->keying_cnt = 1; 1402 1407 srtp->keying[0] = &ds->base; 1403 srtp->keying_pending_cnt = 1;1408 srtp->keying_pending_cnt = 0; 1404 1409 1405 1410 /* Apply param to DTLS-SRTP internal states */ … … 1413 1418 ds->pending_start = PJ_TRUE; 1414 1419 srtp->keying_pending_cnt++; 1415 1416 /* Create SSL */1417 status = ssl_create(ds);1418 if (status != PJ_SUCCESS)1419 goto on_return;1420 1420 1421 1421 /* Attach member transport, so we can send/receive DTLS init packets */
Note: See TracChangeset
for help on using the changeset viewer.