MCPcopy Create free account
hub / github.com/apache/qpid-proton / pn_ssl_init

Function pn_ssl_init

c/src/ssl/schannel.cpp:683–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681static pn_ssl_domain_t *default_server_domain = 0;
682
683int pn_ssl_init(pn_ssl_t *ssl0, pn_ssl_domain_t *domain, const char *session_id)
684{
685 pn_transport_t *transport = get_transport_internal(ssl0);
686 pni_ssl_t *ssl = transport->ssl;
687 if (!ssl) return -1;
688 if (ssl->state != CREATED) return -1;
689
690 if (!domain) {
691 if (transport->server) {
692 if (!default_server_domain) {
693 default_server_domain = pn_ssl_domain(PN_SSL_MODE_SERVER);
694 }
695 domain = default_server_domain;
696 }
697 else {
698 if (!default_client_domain) {
699 default_client_domain = pn_ssl_domain(PN_SSL_MODE_CLIENT);
700 pn_ssl_domain_set_peer_authentication(default_client_domain, PN_SSL_VERIFY_PEER_NAME, NULL);
701 }
702 domain = default_client_domain;
703 }
704 }
705
706 csguard g(&domain->cslock);
707 csguard g2(&domain->cred->cslock);
708 if (session_id && domain->mode == PN_SSL_MODE_CLIENT)
709 ssl->session_id = pn_strdup(session_id);
710
711 // If SSL doesn't specifically allow skipping encryption, require SSL
712 // TODO: This is a probably a stop-gap until allow_unsecured is removed
713 if (!domain->allow_unsecured) transport->encryption_required = true;
714
715 ssl->cred = domain->cred;
716 pn_incref(domain->cred);
717
718 SECURITY_STATUS status = SEC_E_OK;
719 ssl->cred_handle = win_credential_cred_handle(ssl->cred, ssl->session_id, &status);
720 if (status != SEC_E_OK) {
721 ssl_log_error_status(status, "Credentials handle failure");
722 return -1;
723 }
724
725 ssl->state = (domain->mode == PN_SSL_MODE_CLIENT) ? CLIENT_HELLO : NEGOTIATING;
726 ssl->verify_mode = domain->verify_mode;
727 ssl->mode = domain->mode;
728 return 0;
729}
730
731
732int pn_ssl_domain_allow_unsecured_client(pn_ssl_domain_t *domain)

Callers

nothing calls this directly

Calls 7

pn_strdupFunction · 0.85
pn_increfFunction · 0.85
ssl_log_error_statusFunction · 0.85
get_transport_internalFunction · 0.70
pn_ssl_domainFunction · 0.70

Tested by

no test coverage detected