21#define NONAMELESSUNION
67 char *server_auth[] = { oid_server_auth };
78 if (
chain->TrustStatus.dwErrorStatus)
80 static const DWORD supportedErrors =
90 else if (
chain->TrustStatus.dwErrorStatus &
96 else if ((
chain->TrustStatus.dwErrorStatus &
98 (
chain->TrustStatus.dwErrorStatus &
103 else if (
chain->TrustStatus.dwErrorStatus &
109 else if (
chain->TrustStatus.dwErrorStatus & ~supportedErrors)
125 sslExtraPolicyPara.u.
cbSize =
sizeof(sslExtraPolicyPara);
128 sslExtraPolicyPara.
fdwChecks = security_flags;
129 policyPara.
cbSize =
sizeof(policyPara);
133 &chainCopy, &policyPara,
166 else ERR(
"WSAStartup failed: %d\n",
ret );
189 unsigned int addr_len;
196 conn = heap_alloc_zero(
sizeof(*conn));
197 if (!conn)
return NULL;
265 BOOL check_revocation)
270 SIZE_T read_buf_size = 2048;
286 &
ctx, &out_desc, &attrs,
NULL);
298 ERR(
"send failed\n");
304 out_buf.pvBuffer =
NULL;
309 assert(in_bufs[1].cbBuffer < read_buf_size);
311 memmove(
read_buf, (
BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
312 in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
315 in_bufs[1].cbBuffer = 0;
316 in_bufs[1].pvBuffer =
NULL;
322 if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
331 in_bufs[0].pvBuffer =
read_buf = new_read_buf;
332 read_buf_size += 1024;
343 in_bufs[0].cbBuffer +=
size;
347 TRACE(
"InitializeSecurityContext ret %08x\n",
status);
351 FIXME(
"SECBUFFER_EXTRA not supported\n");
355 WARN(
"Could not get sizes\n");
364 WARN(
"cert verify failed: %u\n",
res);
368 WARN(
"Could not get cert\n");
383 WARN(
"Failed to initialize security context failed: %08x\n",
status);
392 TRACE(
"established SSL connection\n");
412 WARN(
"EncryptMessage failed\n");
417 WARN(
"send failed\n");
482 bufs[0].cbBuffer = buf_len;
490 TRACE(
"context expired\n");
494 assert(buf_len < ssl_buf_size);
563 if (!(
flags & MSG_WAITALL) || *recvd ==
len)
return TRUE;
570 WARN(
"read_ssl_chunk failed\n");
602 WARN(
"setsockopt failed (%u)\n",
err );
646 switch (
res->ai_family)
671 struct resolve_args *ra =
arg;
683 struct resolve_args ra;
773 if (!conn->
secure)
return 0;
776 WARN(
"QueryContextAttributesW failed: %08x\n",
res);
INT WSAAPI GetAddrInfoW(IN PCWSTR pszNodeName, IN PCWSTR pszServiceName, IN const ADDRINFOW *ptHints, OUT PADDRINFOW *pptResult)
static struct sockaddr_in sa
static void * heap_alloc(size_t len)
static BOOL heap_free(void *mem)
static void * heap_realloc(void *mem, size_t len)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static HINSTANCE instance
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
BOOL WINAPI CertVerifyCertificateChainPolicy(LPCSTR szPolicyOID, PCCERT_CHAIN_CONTEXT pChainContext, PCERT_CHAIN_POLICY_PARA pPolicyPara, PCERT_CHAIN_POLICY_STATUS pPolicyStatus)
BOOL WINAPI CertGetCertificateChain(HCERTCHAINENGINE hChainEngine, PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore, PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved, PCCERT_CHAIN_CONTEXT *ppChainContext)
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
ULONG netconn_query_data_available(struct netconn *conn)
BOOL netconn_secure_connect(struct netconn *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle, BOOL check_revocation)
const void * netconn_get_certificate(struct netconn *conn)
static void winsock_init(void)
void netconn_close(struct netconn *conn)
BOOL netconn_recv(struct netconn *conn, void *buf, size_t len, int flags, int *recvd)
static BOOL winsock_loaded
static void CALLBACK resolve_proc(TP_CALLBACK_INSTANCE *instance, void *ctx)
void netconn_unload(void)
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **ctx)
static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
static int sock_send(int fd, const void *msg, size_t len, int flags)
BOOL netconn_is_alive(struct netconn *netconn)
static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
BOOL netconn_resolve(WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *addr, int timeout)
BOOL netconn_send(struct netconn *conn, const void *msg, size_t len, int *sent)
static int sock_recv(int fd, void *msg, size_t len, int flags)
DWORD netconn_set_timeout(struct netconn *netconn, BOOL send, int value)
struct netconn * netconn_create(struct hostdata *host, const struct sockaddr_storage *sockaddr, int timeout)
int netconn_get_cipher_strength(struct netconn *conn)
static DWORD netconn_verify_cert(PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags, BOOL check_revocation)
static DWORD resolve_hostname(const WCHAR *name, INTERNET_PORT port, struct sockaddr_storage *sa)
static void set_blocking(struct netconn *conn, BOOL blocking)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
static SecHandle cred_handle
#define ISC_REQ_MANUAL_CRED_VALIDATION
#define ISC_REQ_CONFIDENTIALITY
#define ISC_REQ_ALLOCATE_MEMORY
#define SECBUFFER_STREAM_TRAILER
#define SECBUFFER_STREAM_HEADER
#define ISC_REQ_SEQUENCE_DETECT
#define ISC_REQ_REPLAY_DETECT
#define ISC_REQ_USE_SESSION_KEY
#define SECPKG_ATTR_STREAM_SIZES
#define SECBUFFER_VERSION
void release_host(struct hostdata *host)
#define SECPKG_ATTR_CONNECTION_INFO
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
namespace GUID const ADDRINFOEXW * hints
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
CERT_TRUST_STATUS TrustStatus
CERT_USAGE_MATCH RequestedUsage
LPSTR * rgpszUsageIdentifier
struct sockaddr_storage * addr
SecPkgContext_StreamSizes ssl_sizes
struct sockaddr_storage sockaddr
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
static rfbScreenInfoPtr server
DWORD WINAPI GetLastError(void)
#define INIT_ONCE_STATIC_INIT
#define CERT_TRUST_IS_REVOKED
#define CERT_TRUST_REVOCATION_STATUS_UNKNOWN
#define CERT_TRUST_IS_OFFLINE_REVOCATION
#define szOID_PKIX_KP_SERVER_AUTH
#define CERT_CHAIN_POLICY_SSL
#define CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT
#define CERT_TRUST_IS_NOT_VALID_FOR_USAGE
#define CERT_TRUST_IS_UNTRUSTED_ROOT
#define CERT_TRUST_IS_NOT_TIME_VALID
#define SEC_I_CONTEXT_EXPIRED
#define CERT_E_CN_NO_MATCH
#define SEC_I_CONTINUE_NEEDED
#define SEC_E_INCOMPLETE_MESSAGE
#define ERROR_WINHTTP_NAME_NOT_RESOLVED
#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE
#define ERROR_WINHTTP_SECURE_CERT_REVOKED
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
#define ERROR_WINHTTP_SECURE_CERT_DATE_INVALID
#define ERROR_WINHTTP_TIMEOUT
#define ERROR_WINHTTP_SECURE_INVALID_CERT
#define ERROR_WINHTTP_SECURE_CERT_CN_INVALID
#define ERROR_WINHTTP_SECURE_CERT_REV_FAILED
#define ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR
#define ERROR_WINHTTP_SECURE_INVALID_CA
struct _TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE
int PASCAL FAR WSAGetLastError(void)
int PASCAL FAR WSACleanup(void)
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)