iso.c revision 6e9aa255e3376b2da5824c09c4c62bc233463bfe
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* -*- c-basic-offset: 8 -*-
a180a41bba1d50822df23fff0099e90b86638b89vboxsync rdesktop: A Remote Desktop Protocol client.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Protocol services - ISO layer
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Copyright 2005-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Copyright 2012 Henrik Andersson <hean01@cendio.se> for Cendio AB
a180a41bba1d50822df23fff0099e90b86638b89vboxsync This program is free software: you can redistribute it and/or modify
a180a41bba1d50822df23fff0099e90b86638b89vboxsync it under the terms of the GNU General Public License as published by
a180a41bba1d50822df23fff0099e90b86638b89vboxsync the Free Software Foundation, either version 3 of the License, or
a180a41bba1d50822df23fff0099e90b86638b89vboxsync (at your option) any later version.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync This program is distributed in the hope that it will be useful,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync but WITHOUT ANY WARRANTY; without even the implied warranty of
a180a41bba1d50822df23fff0099e90b86638b89vboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync GNU General Public License for more details.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync You should have received a copy of the GNU General Public License
a180a41bba1d50822df23fff0099e90b86638b89vboxsync along with this program. If not, see <http://www.gnu.org/licenses/>.
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * the General Public License version 2 (GPLv2) at this time for any software where
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * a choice of GPL license versions is made available with the language indicating
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * that GPLv2 or any later version may be used, or where a choice of which version
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * of the GPL is applied is otherwise unspecified.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Send a self-contained ISO PDU */
a180a41bba1d50822df23fff0099e90b86638b89vboxsynciso_send_connection_request(char *username, uint32 neg_proto)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (g_rdp_version >= RDP_V5 && g_negotiate_rdp_protocol)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync out_uint8p(s, "Cookie: mstshash=", strlen("Cookie: mstshash="));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync out_uint8(s, 0x0d); /* cookie termination string: CR+LF */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (g_rdp_version >= RDP_V5 && g_negotiate_rdp_protocol)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* optional rdp protocol negotiation request for RDPv5 */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Receive a message on the ISO layer, return code */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Initialise ISO transport data packet */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Send an ISO data PDU */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Receive ISO transport data packet */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Establish a connection up to the ISO layer */
a180a41bba1d50822df23fff0099e90b86638b89vboxsynciso_connect(char *server, char *username, char *domain, char *password,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else if (g_sc_csp_name || g_sc_reader_name || g_sc_card_name || g_sc_container_name)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync warning("Disables CredSSP due to missing smartcard information for SSO.\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* handle RDP_NEG_REQ response */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync reason = "SSL with user authentication required by server";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync reason = "no valid authentication certificate on server";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Failed to negotiate protocol, retrying with plain RDP.\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(stderr, "Failed to connect, %s.\n", reason);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync error("Expected RDP_NEG_RSP, got type = 0x%x\n", type);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* handle negotiation response */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* failed to connect using cssp, let retry with plain TLS */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* do not use encryption when using TLS */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(stderr, "Connection established using SSL.\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (!cssp_connect(server, username, domain, password, s))
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* failed to connect using cssp, let retry with plain TLS */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* do not use encryption when using TLS */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(stderr, "Connection established using CredSSP.\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(stderr, "Connection established using plain RDP.\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync error("Unexpected protocol in negotiation response, got data = 0x%x.\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Disconnect from the ISO layer */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* reset the state to support reconnecting */