28#define NONAMELESSUNION
56 char *server_auth[] = { oid_server_auth };
59 static const DWORD supportedErrors =
75 errors =
chain->TrustStatus.dwErrorStatus;
80 WARN(
"ERROR_INTERNET_SEC_CERT_REV_FAILED\n");
88 if (
chain->TrustStatus.dwErrorStatus & ~supportedErrors) {
89 WARN(
"error status %x\n",
chain->TrustStatus.dwErrorStatus & ~supportedErrors);
91 errors &= supportedErrors;
94 WARN(
"unknown error flags\n");
98 WARN(
"CERT_TRUST_IS_NOT_TIME_VALID\n");
105 errors &= ~CERT_TRUST_IS_NOT_TIME_VALID;
109 WARN(
"CERT_TRUST_IS_UNTRUSTED_ROOT\n");
116 errors &= ~CERT_TRUST_IS_UNTRUSTED_ROOT;
120 WARN(
"CERT_TRUST_IS_PARTIAL_CHAIN\n");
127 errors &= ~CERT_TRUST_IS_PARTIAL_CHAIN;
131 WARN(
"CERT_TRUST_IS_NOT_SIGNATURE_VALID\n");
138 errors &= ~CERT_TRUST_IS_NOT_SIGNATURE_VALID;
142 WARN(
"CERT_TRUST_IS_NOT_VALID_FOR_USAGE\n");
147 WARN(
"CERT_TRUST_IS_NOT_VALID_FOR_USAGE, unknown error flags\n");
149 errors &= ~CERT_TRUST_IS_NOT_VALID_FOR_USAGE;
170 sslExtraPolicyPara.u.
cbSize =
sizeof(sslExtraPolicyPara);
174 policyPara.
cbSize =
sizeof(policyPara);
178 &chainCopy, &policyPara, &policyStatus);
184 WARN(
"CERT_E_CN_NO_MATCH\n");
188 }
else if(policyStatus.
dwError) {
189 WARN(
"policyStatus.dwError %x\n", policyStatus.
dwError);
191 WARN(
"unknown error flags for policy status %x\n", policyStatus.
dwError);
227 0, 0, { (
DWORD_PTR)(__FILE__
": init_sechandle_cs") }
277 ERR(
"WSAStartup failed: %u\n",
res);
342 WARN(
"setsockopt(TCP_NODELAY) failed\n");
357 netconn->security_flags = security_flags |
server->security_flags;
358 netconn->mask_errors = mask_errors;
446 SIZE_T read_buf_size = 2048;
472 &
ctx, &out_desc, &attrs,
NULL);
486 ERR(
"send failed\n");
492 out_buf.pvBuffer =
NULL;
497 assert(in_bufs[1].cbBuffer < read_buf_size);
499 memmove(
read_buf, (
BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
500 in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
503 in_bufs[1].cbBuffer = 0;
504 in_bufs[1].pvBuffer =
NULL;
510 if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
519 in_bufs[0].pvBuffer =
read_buf = new_read_buf;
520 read_buf_size += 1024;
525 WARN(
"recv error\n");
532 in_bufs[0].cbBuffer +=
size;
536 TRACE(
"InitializeSecurityContext ret %08x\n",
status);
544 FIXME(
"SECBUFFER_EXTRA not supported\n");
548 WARN(
"Could not get sizes\n");
557 WARN(
"cert verify failed: %u\n",
res);
561 WARN(
"Could not get cert\n");
577 WARN(
"Failed to establish SSL connection: %08x (%u)\n",
status,
res);
583 TRACE(
"established SSL connection\n");
610 ERR(
"already connected\n");
652 WARN(
"EncryptMessage failed\n");
657 WARN(
"send failed\n");
725 TRACE(
"would block\n");
728 WARN(
"recv failed\n");
747 bufs[0].cbBuffer = buf_len;
755 TRACE(
"context expired\n");
759 assert(buf_len < ssl_buf_size);
765 TRACE(
"would block\n");
864 WARN(
"read_ssl_chunk failed\n");
906 WARN(
"QueryContextAttributesW failed: %08x\n",
res);
919 WARN(
"setsockopt failed\n");
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 void list_init(struct list_entry *head)
#define ERROR_NOT_ENOUGH_MEMORY
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)
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
void server_release(server_t *server)
void server_addref(server_t *server)
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)
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
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 flag
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 _SECURITY_FLAG_CERT_REV_FAILED
#define _SECURITY_FLAG_CERT_INVALID_CN
#define _SECURITY_ERROR_FLAGS_MASK
#define _SECURITY_FLAG_CERT_INVALID_DATE
#define _SECURITY_FLAG_CERT_INVALID_CA
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
DWORD NETCON_secure_connect(netconn_t *connection, server_t *server)
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blocking, SIZE_T *ret_size, BOOL *eof)
static SecHandle compat_cred_handle
static CRITICAL_SECTION init_sechandle_cs
static BOOL cred_handle_initialized
static CRITICAL_SECTION_DEBUG init_sechandle_cs_debug
static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD timeout)
BOOL is_valid_netconn(netconn_t *netconn)
int NETCON_GetCipherStrength(netconn_t *connection)
static BOOL have_compat_cred_handle
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
int sock_send(int fd, const void *msg, size_t len, int flags)
static BOOL winsock_loaded
DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent)
int sock_recv(int fd, void *msg, size_t len, int flags)
DWORD create_netconn(server_t *server, DWORD security_flags, BOOL mask_errors, DWORD timeout, netconn_t **ret)
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
LPCVOID NETCON_GetCert(netconn_t *connection)
static SecHandle cred_handle
void free_netconn(netconn_t *netconn)
BOOL NETCON_is_alive(netconn_t *netconn)
void close_netconn(netconn_t *netconn)
static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode)
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value)
static DWORD netconn_verify_cert(netconn_t *conn, PCCERT_CONTEXT cert, HCERTSTORE store)
DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, BOOL blocking, int *recvd)
static BOOL ensure_cred_handle(void)
#define ISC_REQ_MANUAL_CRED_VALIDATION
#define ISC_REQ_CONFIDENTIALITY
#define SecIsValidHandle(x)
#define ISC_REQ_ALLOCATE_MEMORY
#define SECPKG_CRED_OUTBOUND
#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 SecInvalidateHandle(x)
#define SECPKG_ATTR_STREAM_SIZES
#define SECBUFFER_VERSION
#define SP_PROT_TLS1_1PLUS_CLIENT
#define SECPKG_ATTR_CONNECTION_INFO
#define SECPKG_ATTR_SUPPORTED_PROTOCOLS
#define SCHANNEL_CRED_VERSION
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *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
LIST_ENTRY ProcessLocksList
LPSTR * rgpszUsageIdentifier
DWORD grbitEnabledProtocols
SecPkgContext_StreamSizes ssl_sizes
const CERT_CHAIN_CONTEXT * cert_chain
static rfbScreenInfoPtr server
DWORD WINAPI GetLastError(void)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define INIT_ONCE_STATIC_INIT
#define szOID_PKIX_KP_SERVER_AUTH
#define CERT_CHAIN_POLICY_SSL
#define CERT_TRUST_IS_PARTIAL_CHAIN
#define CERT_TRUST_IS_NOT_VALID_FOR_USAGE
#define CERT_TRUST_IS_NOT_SIGNATURE_VALID
#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 SECURITY_FLAG_STRENGTH_MEDIUM
#define SECURITY_FLAG_STRENGTH_WEAK
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
#define SECURITY_FLAG_SECURE
#define SECURITY_FLAG_STRENGTH_STRONG
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
#define ERROR_INTERNET_SEC_CERT_CN_INVALID
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
#define ERROR_INTERNET_CONNECTION_ABORTED
#define ERROR_INTERNET_INVALID_CA
#define ERROR_INTERNET_SEC_CERT_DATE_INVALID
#define SECURITY_FLAG_IGNORE_WRONG_USAGE
#define SECURITY_FLAG_IGNORE_REVOCATION
#define ERROR_INTERNET_CANNOT_CONNECT
#define ERROR_INTERNET_SEC_CERT_REV_FAILED
#define ERROR_INTERNET_SEC_CERT_ERRORS
#define ERROR_INTERNET_SEC_INVALID_CERT
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 AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
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 QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)