2012-06-13 09:53:51 -04:00
|
|
|
#ifndef HEADER_CURL_SCHANNEL_H
|
|
|
|
#define HEADER_CURL_SCHANNEL_H
|
2012-04-09 09:40:06 -04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, Marc Hoersken, <info@marc-hoersken.de>, et al.
|
2017-01-12 11:41:26 -05:00
|
|
|
* Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2012-04-09 09:40:06 -04:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2016-02-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2012-04-09 09:40:06 -04:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2013-01-06 13:06:49 -05:00
|
|
|
#include "curl_setup.h"
|
2012-04-09 09:40:06 -04:00
|
|
|
|
|
|
|
#ifdef USE_SCHANNEL
|
|
|
|
|
schannel: add support for CURLOPT_CAINFO
- Move verify_certificate functionality in schannel.c into a new
file called schannel_verify.c. Additionally, some structure defintions
from schannel.c have been moved to schannel.h to allow them to be
used in schannel_verify.c.
- Make verify_certificate functionality for Schannel available on
all versions of Windows instead of just Windows CE. verify_certificate
will be invoked on Windows CE or when the user specifies
CURLOPT_CAINFO and CURLOPT_SSL_VERIFYPEER.
- In verify_certificate, create a custom certificate chain engine that
exclusively trusts the certificate store backed by the CURLOPT_CAINFO
file.
- doc updates of --cacert/CAINFO support for schannel
- Use CERT_NAME_SEARCH_ALL_NAMES_FLAG when invoking CertGetNameString
when available. This implements a TODO in schannel.c to improve
handling of multiple SANs in a certificate. In particular, all SANs
will now be searched instead of just the first name.
- Update tool_operate.c to not search for the curl-ca-bundle.crt file
when using Schannel to maintain backward compatibility. Previously,
any curl-ca-bundle.crt file found in that search would have been
ignored by Schannel. But, with CAINFO support, the file found by
that search would have been used as the certificate store and
could cause issues for any users that have curl-ca-bundle.crt in
the search path.
- Update url.c to not set the build time CURL_CA_BUNDLE if the selected
SSL backend is Schannel. We allow setting CA location for schannel
only when explicitly specified by the user via CURLOPT_CAINFO /
--cacert.
- Add new test cases 3000 and 3001. These test cases check that the first
and last SAN, respectively, matches the connection hostname. New test
certificates have been added for these cases. For 3000, the certificate
prefix is Server-localhost-firstSAN and for 3001, the certificate
prefix is Server-localhost-secondSAN.
- Remove TODO 15.2 (Add support for custom server certificate
validation), this commit addresses it.
Closes https://github.com/curl/curl/pull/1325
2017-03-10 15:27:30 -05:00
|
|
|
#include <schnlsp.h>
|
|
|
|
#include <schannel.h>
|
|
|
|
#include "curl_sspi.h"
|
|
|
|
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "urldata.h"
|
2012-04-09 17:24:55 -04:00
|
|
|
|
2018-06-08 09:10:05 -04:00
|
|
|
/* <wincrypt.h> has been included via the above <schnlsp.h>.
|
|
|
|
* Or in case of ldap.c, it was included via <winldap.h>.
|
|
|
|
* And since <wincrypt.h> has this:
|
|
|
|
* #define X509_NAME ((LPCSTR) 7)
|
|
|
|
*
|
|
|
|
* And in BoringSSL's <openssl/base.h> there is:
|
|
|
|
* typedef struct X509_name_st X509_NAME;
|
|
|
|
* etc.
|
|
|
|
*
|
2018-10-08 15:37:40 -04:00
|
|
|
* this will cause all kinds of C-preprocessing paste errors in
|
2018-06-08 09:10:05 -04:00
|
|
|
* BoringSSL's <openssl/x509.h>: So just undefine those defines here
|
|
|
|
* (and only here).
|
|
|
|
*/
|
|
|
|
#if defined(HAVE_BORINGSSL) || defined(OPENSSL_IS_BORINGSSL)
|
|
|
|
# undef X509_NAME
|
|
|
|
# undef X509_CERT_PAIR
|
|
|
|
# undef X509_EXTENSIONS
|
|
|
|
#endif
|
|
|
|
|
2017-06-22 10:45:34 -04:00
|
|
|
extern const struct Curl_ssl Curl_ssl_schannel;
|
|
|
|
|
schannel: add support for CURLOPT_CAINFO
- Move verify_certificate functionality in schannel.c into a new
file called schannel_verify.c. Additionally, some structure defintions
from schannel.c have been moved to schannel.h to allow them to be
used in schannel_verify.c.
- Make verify_certificate functionality for Schannel available on
all versions of Windows instead of just Windows CE. verify_certificate
will be invoked on Windows CE or when the user specifies
CURLOPT_CAINFO and CURLOPT_SSL_VERIFYPEER.
- In verify_certificate, create a custom certificate chain engine that
exclusively trusts the certificate store backed by the CURLOPT_CAINFO
file.
- doc updates of --cacert/CAINFO support for schannel
- Use CERT_NAME_SEARCH_ALL_NAMES_FLAG when invoking CertGetNameString
when available. This implements a TODO in schannel.c to improve
handling of multiple SANs in a certificate. In particular, all SANs
will now be searched instead of just the first name.
- Update tool_operate.c to not search for the curl-ca-bundle.crt file
when using Schannel to maintain backward compatibility. Previously,
any curl-ca-bundle.crt file found in that search would have been
ignored by Schannel. But, with CAINFO support, the file found by
that search would have been used as the certificate store and
could cause issues for any users that have curl-ca-bundle.crt in
the search path.
- Update url.c to not set the build time CURL_CA_BUNDLE if the selected
SSL backend is Schannel. We allow setting CA location for schannel
only when explicitly specified by the user via CURLOPT_CAINFO /
--cacert.
- Add new test cases 3000 and 3001. These test cases check that the first
and last SAN, respectively, matches the connection hostname. New test
certificates have been added for these cases. For 3000, the certificate
prefix is Server-localhost-firstSAN and for 3001, the certificate
prefix is Server-localhost-secondSAN.
- Remove TODO 15.2 (Add support for custom server certificate
validation), this commit addresses it.
Closes https://github.com/curl/curl/pull/1325
2017-03-10 15:27:30 -05:00
|
|
|
CURLcode verify_certificate(struct connectdata *conn, int sockindex);
|
|
|
|
|
|
|
|
/* structs to expose only in schannel.c and schannel_verify.c */
|
|
|
|
#ifdef EXPOSE_SCHANNEL_INTERNAL_STRUCTS
|
2018-05-16 02:02:29 -04:00
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <_mingw.h>
|
|
|
|
#ifdef __MINGW64_VERSION_MAJOR
|
|
|
|
#define HAS_MANUAL_VERIFY_API
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#include <wincrypt.h>
|
|
|
|
#ifdef CERT_CHAIN_REVOCATION_CHECK_CHAIN
|
|
|
|
#define HAS_MANUAL_VERIFY_API
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
schannel: add support for CURLOPT_CAINFO
- Move verify_certificate functionality in schannel.c into a new
file called schannel_verify.c. Additionally, some structure defintions
from schannel.c have been moved to schannel.h to allow them to be
used in schannel_verify.c.
- Make verify_certificate functionality for Schannel available on
all versions of Windows instead of just Windows CE. verify_certificate
will be invoked on Windows CE or when the user specifies
CURLOPT_CAINFO and CURLOPT_SSL_VERIFYPEER.
- In verify_certificate, create a custom certificate chain engine that
exclusively trusts the certificate store backed by the CURLOPT_CAINFO
file.
- doc updates of --cacert/CAINFO support for schannel
- Use CERT_NAME_SEARCH_ALL_NAMES_FLAG when invoking CertGetNameString
when available. This implements a TODO in schannel.c to improve
handling of multiple SANs in a certificate. In particular, all SANs
will now be searched instead of just the first name.
- Update tool_operate.c to not search for the curl-ca-bundle.crt file
when using Schannel to maintain backward compatibility. Previously,
any curl-ca-bundle.crt file found in that search would have been
ignored by Schannel. But, with CAINFO support, the file found by
that search would have been used as the certificate store and
could cause issues for any users that have curl-ca-bundle.crt in
the search path.
- Update url.c to not set the build time CURL_CA_BUNDLE if the selected
SSL backend is Schannel. We allow setting CA location for schannel
only when explicitly specified by the user via CURLOPT_CAINFO /
--cacert.
- Add new test cases 3000 and 3001. These test cases check that the first
and last SAN, respectively, matches the connection hostname. New test
certificates have been added for these cases. For 3000, the certificate
prefix is Server-localhost-firstSAN and for 3001, the certificate
prefix is Server-localhost-secondSAN.
- Remove TODO 15.2 (Add support for custom server certificate
validation), this commit addresses it.
Closes https://github.com/curl/curl/pull/1325
2017-03-10 15:27:30 -05:00
|
|
|
struct curl_schannel_cred {
|
|
|
|
CredHandle cred_handle;
|
|
|
|
TimeStamp time_stamp;
|
|
|
|
int refcount;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct curl_schannel_ctxt {
|
|
|
|
CtxtHandle ctxt_handle;
|
|
|
|
TimeStamp time_stamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ssl_backend_data {
|
|
|
|
struct curl_schannel_cred *cred;
|
|
|
|
struct curl_schannel_ctxt *ctxt;
|
|
|
|
SecPkgContext_StreamSizes stream_sizes;
|
|
|
|
size_t encdata_length, decdata_length;
|
|
|
|
size_t encdata_offset, decdata_offset;
|
|
|
|
unsigned char *encdata_buffer, *decdata_buffer;
|
|
|
|
/* encdata_is_incomplete: if encdata contains only a partial record that
|
|
|
|
can't be decrypted without another Curl_read_plain (that is, status is
|
|
|
|
SEC_E_INCOMPLETE_MESSAGE) then set this true. after Curl_read_plain writes
|
|
|
|
more bytes into encdata then set this back to false. */
|
|
|
|
bool encdata_is_incomplete;
|
|
|
|
unsigned long req_flags, ret_flags;
|
|
|
|
CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */
|
|
|
|
bool recv_sspi_close_notify; /* true if connection closed by close_notify */
|
|
|
|
bool recv_connection_closed; /* true if connection closed, regardless how */
|
|
|
|
bool use_alpn; /* true if ALPN is used for this connection */
|
2018-05-16 02:02:29 -04:00
|
|
|
#ifdef HAS_MANUAL_VERIFY_API
|
schannel: add support for CURLOPT_CAINFO
- Move verify_certificate functionality in schannel.c into a new
file called schannel_verify.c. Additionally, some structure defintions
from schannel.c have been moved to schannel.h to allow them to be
used in schannel_verify.c.
- Make verify_certificate functionality for Schannel available on
all versions of Windows instead of just Windows CE. verify_certificate
will be invoked on Windows CE or when the user specifies
CURLOPT_CAINFO and CURLOPT_SSL_VERIFYPEER.
- In verify_certificate, create a custom certificate chain engine that
exclusively trusts the certificate store backed by the CURLOPT_CAINFO
file.
- doc updates of --cacert/CAINFO support for schannel
- Use CERT_NAME_SEARCH_ALL_NAMES_FLAG when invoking CertGetNameString
when available. This implements a TODO in schannel.c to improve
handling of multiple SANs in a certificate. In particular, all SANs
will now be searched instead of just the first name.
- Update tool_operate.c to not search for the curl-ca-bundle.crt file
when using Schannel to maintain backward compatibility. Previously,
any curl-ca-bundle.crt file found in that search would have been
ignored by Schannel. But, with CAINFO support, the file found by
that search would have been used as the certificate store and
could cause issues for any users that have curl-ca-bundle.crt in
the search path.
- Update url.c to not set the build time CURL_CA_BUNDLE if the selected
SSL backend is Schannel. We allow setting CA location for schannel
only when explicitly specified by the user via CURLOPT_CAINFO /
--cacert.
- Add new test cases 3000 and 3001. These test cases check that the first
and last SAN, respectively, matches the connection hostname. New test
certificates have been added for these cases. For 3000, the certificate
prefix is Server-localhost-firstSAN and for 3001, the certificate
prefix is Server-localhost-secondSAN.
- Remove TODO 15.2 (Add support for custom server certificate
validation), this commit addresses it.
Closes https://github.com/curl/curl/pull/1325
2017-03-10 15:27:30 -05:00
|
|
|
bool use_manual_cred_validation; /* true if manual cred validation is used */
|
2018-05-16 02:02:29 -04:00
|
|
|
#endif
|
schannel: add support for CURLOPT_CAINFO
- Move verify_certificate functionality in schannel.c into a new
file called schannel_verify.c. Additionally, some structure defintions
from schannel.c have been moved to schannel.h to allow them to be
used in schannel_verify.c.
- Make verify_certificate functionality for Schannel available on
all versions of Windows instead of just Windows CE. verify_certificate
will be invoked on Windows CE or when the user specifies
CURLOPT_CAINFO and CURLOPT_SSL_VERIFYPEER.
- In verify_certificate, create a custom certificate chain engine that
exclusively trusts the certificate store backed by the CURLOPT_CAINFO
file.
- doc updates of --cacert/CAINFO support for schannel
- Use CERT_NAME_SEARCH_ALL_NAMES_FLAG when invoking CertGetNameString
when available. This implements a TODO in schannel.c to improve
handling of multiple SANs in a certificate. In particular, all SANs
will now be searched instead of just the first name.
- Update tool_operate.c to not search for the curl-ca-bundle.crt file
when using Schannel to maintain backward compatibility. Previously,
any curl-ca-bundle.crt file found in that search would have been
ignored by Schannel. But, with CAINFO support, the file found by
that search would have been used as the certificate store and
could cause issues for any users that have curl-ca-bundle.crt in
the search path.
- Update url.c to not set the build time CURL_CA_BUNDLE if the selected
SSL backend is Schannel. We allow setting CA location for schannel
only when explicitly specified by the user via CURLOPT_CAINFO /
--cacert.
- Add new test cases 3000 and 3001. These test cases check that the first
and last SAN, respectively, matches the connection hostname. New test
certificates have been added for these cases. For 3000, the certificate
prefix is Server-localhost-firstSAN and for 3001, the certificate
prefix is Server-localhost-secondSAN.
- Remove TODO 15.2 (Add support for custom server certificate
validation), this commit addresses it.
Closes https://github.com/curl/curl/pull/1325
2017-03-10 15:27:30 -05:00
|
|
|
};
|
|
|
|
#endif /* EXPOSE_SCHANNEL_INTERNAL_STRUCTS */
|
|
|
|
|
2012-04-09 09:40:06 -04:00
|
|
|
#endif /* USE_SCHANNEL */
|
2012-06-13 09:53:51 -04:00
|
|
|
#endif /* HEADER_CURL_SCHANNEL_H */
|