Changeset 6014
- Timestamp:
- May 29, 2019 3:49:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r6006 r6014 1567 1567 } 1568 1568 1569 /* Update remote certificates chain info. This function should be 1570 * called after handshake or renegotiation successfully completed. 1571 */ 1572 static void ssl_update_remote_cert_chain_info(pj_pool_t *pool, 1573 pj_ssl_cert_info *ci, 1574 STACK_OF(X509) *chain, 1575 pj_bool_t get_pem) 1576 { 1577 int i; 1578 1579 ci->raw_chain.cert_raw = (pj_str_t *)pj_pool_calloc(pool, 1580 sk_X509_num(chain), 1581 sizeof(pj_str_t)); 1582 ci->raw_chain.cnt = sk_X509_num(chain); 1583 1584 for (i = 0; i < sk_X509_num(chain); i++) { 1585 BIO *bio; 1586 BUF_MEM *ptr; 1587 X509 *x = sk_X509_value(chain, i); 1588 1589 bio = BIO_new(BIO_s_mem()); 1590 1591 if (!PEM_write_bio_X509(bio, x)) { 1592 PJ_LOG(3, (THIS_FILE, "Error retrieving raw certificate info")); 1593 ci->raw_chain.cert_raw[i].ptr = NULL; 1594 ci->raw_chain.cert_raw[i].slen = 0; 1595 } else { 1596 BIO_write(bio, "\0", 1); 1597 BIO_get_mem_ptr(bio, &ptr); 1598 pj_strdup2(pool, &ci->raw_chain.cert_raw[i], ptr->data ); 1599 } 1600 1601 BIO_free(bio); 1602 } 1603 } 1569 1604 1570 1605 /* Update local & remote certificates info. This function should be … … 1575 1610 ossl_sock_t *ossock = (ossl_sock_t *)ssock; 1576 1611 X509 *x; 1612 STACK_OF(X509) *chain; 1577 1613 1578 1614 pj_assert(ssock->ssl_state == SSL_STATE_ESTABLISHED); … … 1595 1631 } else { 1596 1632 pj_bzero(&ssock->remote_cert_info, sizeof(pj_ssl_cert_info)); 1633 } 1634 1635 chain = SSL_get_peer_cert_chain(ossock->ossl_ssl); 1636 if (chain) { 1637 ssl_update_remote_cert_chain_info(ssock->pool, 1638 &ssock->remote_cert_info, 1639 chain, PJ_TRUE); 1640 } else { 1641 ssock->remote_cert_info.raw_chain.cnt = 0; 1597 1642 } 1598 1643 }
Note: See TracChangeset
for help on using the changeset viewer.