13 #include "tlsschannelclient.h"
39 if( m_haveCredentialsHandle )
46 SECURITY_STATUS error;
51 SCHANNEL_CRED tlscred;
52 ULONG request = ISC_REQ_ALLOCATE_MEMORY
53 | ISC_REQ_CONFIDENTIALITY
54 | ISC_REQ_EXTENDED_ERROR
56 | ISC_REQ_REPLAY_DETECT
57 | ISC_REQ_SEQUENCE_DETECT
59 | ISC_REQ_MANUAL_CRED_VALIDATION;
62 memset( &tlscred, 0,
sizeof( SCHANNEL_CRED ) );
63 tlscred.dwVersion = SCHANNEL_CRED_VERSION;
64 tlscred.grbitEnabledProtocols = SP_PROT_TLS1_CLIENT;
66 error = AcquireCredentialsHandle( 0,
76 if( error != SEC_E_OK )
87 obuf[0].BufferType = SECBUFFER_TOKEN;
89 obufs.ulVersion = SECBUFFER_VERSION;
91 obufs.pBuffers = obuf;
93 SEC_CHAR* hname =
const_cast<char*
>( m_server.c_str() );
95 error = InitializeSecurityContextA( &m_credHandle,
109 if( error == SEC_I_CONTINUE_NEEDED )
113 std::string senddata( static_cast<char*>( obuf[0].pvBuffer ), obuf[0].cbBuffer );
114 FreeContextBuffer( obuf[0].pvBuffer );
115 m_haveCredentialsHandle =
true;
128 void SChannelClient::handshakeStage()
132 SECURITY_STATUS error;
135 SecBuffer ibuf[2], obuf[1];
136 SecBufferDesc ibufs, obufs;
137 ULONG request = ISC_REQ_ALLOCATE_MEMORY
138 | ISC_REQ_CONFIDENTIALITY
139 | ISC_REQ_EXTENDED_ERROR
141 | ISC_REQ_REPLAY_DETECT
142 | ISC_REQ_SEQUENCE_DETECT
144 | ISC_REQ_MANUAL_CRED_VALIDATION;
146 SEC_CHAR* hname =
const_cast<char*
>( m_server.c_str() );
151 ibuf[0].cbBuffer =
static_cast<unsigned long>( m_buffer.size() );
152 ibuf[0].pvBuffer =
static_cast<void*
>(
const_cast<char*
>( m_buffer.c_str() ) );
154 ibuf[1].cbBuffer = 0;
155 ibuf[1].pvBuffer = 0;
156 obuf[0].cbBuffer = 0;
157 obuf[0].pvBuffer = 0;
159 ibuf[0].BufferType = SECBUFFER_TOKEN;
160 ibuf[1].BufferType = SECBUFFER_EMPTY;
161 obuf[0].BufferType = SECBUFFER_EMPTY;
163 ibufs.ulVersion = obufs.ulVersion = SECBUFFER_VERSION;
166 ibufs.pBuffers = ibuf;
167 obufs.pBuffers = obuf;
176 error = InitializeSecurityContextA( &m_credHandle,
189 if( error == SEC_E_OK )
192 if( ibuf[1].BufferType == SECBUFFER_EXTRA )
194 m_buffer.erase( 0, m_buffer.size() - ibuf[1].cbBuffer );
207 else if( error == SEC_I_CONTINUE_NEEDED )
216 if( obuf[0].cbBuffer != 0 && obuf[0].pvBuffer != 0 )
218 std::string senddata( static_cast<char*>(obuf[0].pvBuffer), obuf[0].cbBuffer );
219 FreeContextBuffer( obuf[0].pvBuffer );
223 if( ibuf[1].BufferType == SECBUFFER_EXTRA )
225 m_buffer.erase( 0, m_buffer.size() - ibuf[1].cbBuffer );
229 if( obuf[0].cbBuffer == 0 )
238 else if( error == SEC_I_INCOMPLETE_CREDENTIALS )
242 else if( error == SEC_E_INCOMPLETE_MESSAGE )
258 #endif // HAVE_WINTLS