libfreerdp-core: remove TlsIn/TlsOut from rdpTransport
This commit is contained in:
parent
0d85dfd395
commit
889ccefe0d
@ -506,6 +506,18 @@ void rpc_in_channel_free(RpcInChannel* inChannel)
|
||||
|
||||
rpc_in_channel_rpch_uninit(inChannel);
|
||||
|
||||
if (inChannel->tls)
|
||||
{
|
||||
tls_free(inChannel->tls);
|
||||
inChannel->tls = NULL;
|
||||
}
|
||||
|
||||
if (inChannel->tcp)
|
||||
{
|
||||
freerdp_tcp_free(inChannel->tcp);
|
||||
inChannel->tcp = NULL;
|
||||
}
|
||||
|
||||
free(inChannel);
|
||||
}
|
||||
|
||||
@ -645,6 +657,18 @@ void rpc_out_channel_free(RpcOutChannel* outChannel)
|
||||
|
||||
rpc_out_channel_rpch_uninit(outChannel);
|
||||
|
||||
if (outChannel->tls)
|
||||
{
|
||||
tls_free(outChannel->tls);
|
||||
outChannel->tls = NULL;
|
||||
}
|
||||
|
||||
if (outChannel->tcp)
|
||||
{
|
||||
freerdp_tcp_free(outChannel->tcp);
|
||||
outChannel->tcp = NULL;
|
||||
}
|
||||
|
||||
free(outChannel);
|
||||
}
|
||||
|
||||
|
@ -1485,9 +1485,7 @@ BOOL tsg_connect(rdpTsg* tsg, const char* hostname, UINT16 port, int timeout)
|
||||
|
||||
transport->frontBio = tsg->bio;
|
||||
transport->TcpIn = inChannel->tcp;
|
||||
transport->TlsIn = inChannel->tls;
|
||||
transport->TcpOut = outChannel->tcp;
|
||||
transport->TlsOut = outChannel->tls;
|
||||
transport->GatewayEvent = rpc->client->PipeEvent;
|
||||
transport->SplitInputOutput = TRUE;
|
||||
transport->layer = TRANSPORT_LAYER_TSG;
|
||||
@ -1636,8 +1634,6 @@ void tsg_free(rdpTsg* tsg)
|
||||
{
|
||||
if (tsg)
|
||||
{
|
||||
rdpTransport* transport = tsg->transport;
|
||||
|
||||
if (tsg->bio)
|
||||
{
|
||||
BIO_free(tsg->bio);
|
||||
@ -1653,18 +1649,6 @@ void tsg_free(rdpTsg* tsg)
|
||||
free(tsg->Hostname);
|
||||
free(tsg->MachineName);
|
||||
|
||||
if (transport->TlsIn)
|
||||
tls_free(transport->TlsIn);
|
||||
|
||||
if (transport->TcpIn)
|
||||
freerdp_tcp_free(transport->TcpIn);
|
||||
|
||||
if (transport->TlsOut)
|
||||
tls_free(transport->TlsOut);
|
||||
|
||||
if (transport->TcpOut)
|
||||
freerdp_tcp_free(transport->TcpOut);
|
||||
|
||||
free(tsg);
|
||||
}
|
||||
}
|
||||
|
@ -220,11 +220,11 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
|
||||
|
||||
int credssp_ntlm_server_init(rdpCredssp* credssp)
|
||||
{
|
||||
freerdp* instance;
|
||||
rdpSettings* settings = credssp->settings;
|
||||
instance = (freerdp*) settings->instance;
|
||||
sspi_SecBufferAlloc(&credssp->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
|
||||
CopyMemory(credssp->PublicKey.pvBuffer, credssp->transport->TlsIn->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
|
||||
rdpTls* tls = credssp->transport->tls;
|
||||
|
||||
sspi_SecBufferAlloc(&credssp->PublicKey, tls->PublicKeyLength);
|
||||
CopyMemory(credssp->PublicKey.pvBuffer, tls->PublicKey, tls->PublicKeyLength);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -74,62 +74,6 @@ void transport_attach(rdpTransport* transport, int sockfd)
|
||||
transport->frontBio = transport->TcpIn->bufferedBio;
|
||||
}
|
||||
|
||||
void transport_stop(rdpTransport* transport)
|
||||
{
|
||||
if (transport->async)
|
||||
{
|
||||
if (transport->stopEvent)
|
||||
{
|
||||
SetEvent(transport->stopEvent);
|
||||
WaitForSingleObject(transport->thread, INFINITE);
|
||||
CloseHandle(transport->thread);
|
||||
CloseHandle(transport->stopEvent);
|
||||
transport->thread = NULL;
|
||||
transport->stopEvent = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL transport_disconnect(rdpTransport* transport)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
|
||||
if (!transport)
|
||||
return FALSE;
|
||||
|
||||
transport_stop(transport);
|
||||
|
||||
if (transport->tsg)
|
||||
{
|
||||
if (transport->TsgTls)
|
||||
{
|
||||
tls_free(transport->TsgTls);
|
||||
transport->TsgTls = NULL;
|
||||
}
|
||||
|
||||
tsg_free(transport->tsg);
|
||||
transport->tsg = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (transport->TlsIn)
|
||||
tls_free(transport->TlsIn);
|
||||
|
||||
if (transport->TcpIn)
|
||||
freerdp_tcp_free(transport->TcpIn);
|
||||
}
|
||||
|
||||
transport->TlsIn = NULL;
|
||||
transport->TlsOut = NULL;
|
||||
|
||||
transport->TcpIn = NULL;
|
||||
transport->TcpOut = NULL;
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TCP;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL transport_connect_rdp(rdpTransport* transport)
|
||||
{
|
||||
/* RDP encryption */
|
||||
@ -138,41 +82,39 @@ BOOL transport_connect_rdp(rdpTransport* transport)
|
||||
|
||||
BOOL transport_connect_tls(rdpTransport* transport)
|
||||
{
|
||||
int tls_status;
|
||||
BIO* targetBio = NULL;
|
||||
rdpTls* targetTls = NULL;
|
||||
int tlsStatus;
|
||||
BIO* bio = NULL;
|
||||
rdpTls* tls = NULL;
|
||||
rdpContext* context = transport->context;
|
||||
rdpSettings* settings = transport->settings;
|
||||
|
||||
if (transport->GatewayEnabled)
|
||||
{
|
||||
transport->TsgTls = tls_new(transport->settings);
|
||||
tls = transport->tls = tls_new(transport->settings);
|
||||
transport->layer = TRANSPORT_LAYER_TSG_TLS;
|
||||
targetTls = transport->TsgTls;
|
||||
targetBio = transport->frontBio;
|
||||
bio = transport->frontBio;
|
||||
}
|
||||
else
|
||||
{
|
||||
transport->TlsIn = tls_new(settings);
|
||||
targetTls = transport->TlsIn;
|
||||
targetBio = transport->TcpIn->bufferedBio;
|
||||
transport->tls = tls_new(settings);
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
bio = transport->TcpIn->bufferedBio;
|
||||
}
|
||||
|
||||
transport->tls = targetTls;
|
||||
transport->tls = tls;
|
||||
|
||||
targetTls->hostname = settings->ServerHostname;
|
||||
targetTls->port = settings->ServerPort;
|
||||
tls->hostname = settings->ServerHostname;
|
||||
tls->port = settings->ServerPort;
|
||||
|
||||
if (targetTls->port == 0)
|
||||
targetTls->port = 3389;
|
||||
if (tls->port == 0)
|
||||
tls->port = 3389;
|
||||
|
||||
targetTls->isGatewayTransport = FALSE;
|
||||
tls_status = tls_connect(targetTls, targetBio);
|
||||
tls->isGatewayTransport = FALSE;
|
||||
tlsStatus = tls_connect(tls, bio);
|
||||
|
||||
if (tls_status < 1)
|
||||
if (tlsStatus < 1)
|
||||
{
|
||||
if (tls_status < 0)
|
||||
if (tlsStatus < 0)
|
||||
{
|
||||
if (!connectErrorCode)
|
||||
connectErrorCode = TLSCONNECTERROR;
|
||||
@ -189,7 +131,7 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
transport->frontBio = targetTls->bio;
|
||||
transport->frontBio = tls->bio;
|
||||
|
||||
if (!transport->frontBio)
|
||||
{
|
||||
@ -324,15 +266,16 @@ BOOL transport_accept_tls(rdpTransport* transport)
|
||||
{
|
||||
rdpSettings* settings = transport->settings;
|
||||
|
||||
if (!transport->TlsIn)
|
||||
transport->TlsIn = tls_new(transport->settings);
|
||||
if (!transport->tls)
|
||||
transport->tls = tls_new(transport->settings);
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
|
||||
if (!tls_accept(transport->TlsIn, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||
if (!tls_accept(transport->tls, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||
return FALSE;
|
||||
|
||||
transport->frontBio = transport->TlsIn->bio;
|
||||
transport->frontBio = transport->tls->bio;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -341,15 +284,15 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
||||
rdpSettings* settings = transport->settings;
|
||||
freerdp* instance = (freerdp*) settings->instance;
|
||||
|
||||
if (!transport->TlsIn)
|
||||
transport->TlsIn = tls_new(transport->settings);
|
||||
if (!transport->tls)
|
||||
transport->tls = tls_new(transport->settings);
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
|
||||
if (!tls_accept(transport->TlsIn, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||
if (!tls_accept(transport->tls, transport->TcpIn->bufferedBio, settings->CertificateFile, settings->PrivateKeyFile))
|
||||
return FALSE;
|
||||
|
||||
transport->frontBio = transport->TlsIn->bio;
|
||||
transport->frontBio = transport->tls->bio;
|
||||
|
||||
/* Network Level Authentication */
|
||||
|
||||
@ -368,7 +311,7 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
credssp_free(transport->credssp);
|
||||
transport->credssp = NULL;
|
||||
tls_set_alert_code(transport->TlsIn, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
|
||||
tls_set_alert_code(transport->tls, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -898,6 +841,59 @@ void transport_set_nla_mode(rdpTransport* transport, BOOL NlaMode)
|
||||
transport->NlaMode = NlaMode;
|
||||
}
|
||||
|
||||
void transport_stop(rdpTransport* transport)
|
||||
{
|
||||
if (transport->async)
|
||||
{
|
||||
if (transport->stopEvent)
|
||||
{
|
||||
SetEvent(transport->stopEvent);
|
||||
WaitForSingleObject(transport->thread, INFINITE);
|
||||
CloseHandle(transport->thread);
|
||||
CloseHandle(transport->stopEvent);
|
||||
transport->thread = NULL;
|
||||
transport->stopEvent = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL transport_disconnect(rdpTransport* transport)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
|
||||
if (!transport)
|
||||
return FALSE;
|
||||
|
||||
transport_stop(transport);
|
||||
|
||||
if (transport->tsg)
|
||||
{
|
||||
if (transport->tls)
|
||||
{
|
||||
tls_free(transport->tls);
|
||||
transport->tls = NULL;
|
||||
}
|
||||
|
||||
tsg_free(transport->tsg);
|
||||
transport->tsg = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (transport->tls)
|
||||
tls_free(transport->tls);
|
||||
|
||||
if (transport->TcpIn)
|
||||
freerdp_tcp_free(transport->TcpIn);
|
||||
}
|
||||
|
||||
transport->TcpIn = NULL;
|
||||
transport->TcpOut = NULL;
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TCP;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static void* transport_client_thread(void* arg)
|
||||
{
|
||||
DWORD status;
|
||||
|
@ -60,9 +60,6 @@ struct rdp_transport
|
||||
rdpTls* tls;
|
||||
rdpTcp* TcpIn;
|
||||
rdpTcp* TcpOut;
|
||||
rdpTls* TlsIn;
|
||||
rdpTls* TlsOut;
|
||||
rdpTls* TsgTls;
|
||||
rdpContext* context;
|
||||
rdpCredssp* credssp;
|
||||
rdpSettings* settings;
|
||||
|
Loading…
Reference in New Issue
Block a user