Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit a86cce3

Browse files
Benjamin Segaultvinjiang
authored andcommitted
Allow to skip HTTPS certificates validation
1 parent 58b2061 commit a86cce3

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

Microsoft.WindowsAzure.Storage/includes/was/common.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,28 @@ namespace azure { namespace storage {
27012701
m_http_buffer_size = http_buffer_size;
27022702
}
27032703

2704+
/// <summary>
2705+
/// Gets the server certificate validation property.
2706+
/// </summary>
2707+
/// <returns>True if certificates are to be verified, false otherwise</returns>
2708+
bool validate_certificates() const
2709+
{
2710+
return m_validate_certificates;
2711+
}
2712+
2713+
/// <summary>
2714+
/// Sets the server certificate validation property.
2715+
/// </summary>
2716+
/// <param name="validate_certificates">False to disable all server certificate validation, true otherwise.</param>
2717+
/// <remarks>
2718+
/// Disabling certificate validation is not recommended and will make the user exposed to unsecure environment.
2719+
/// Please use with caution and at your own risk.
2720+
/// </remarks>
2721+
void set_validate_certificates(bool validate_certificates)
2722+
{
2723+
m_validate_certificates = validate_certificates;
2724+
}
2725+
27042726
/// <summary>
27052727
/// Gets the expiry time across all potential retries for the request.
27062728
/// </summary>
@@ -2735,6 +2757,7 @@ namespace azure { namespace storage {
27352757
m_maximum_execution_time.merge(other.m_maximum_execution_time);
27362758
m_location_mode.merge(other.m_location_mode);
27372759
m_http_buffer_size.merge(other.m_http_buffer_size);
2760+
m_validate_certificates.merge(other.m_validate_certificates);
27382761

27392762
if (apply_expiry)
27402763
{
@@ -2759,6 +2782,7 @@ namespace azure { namespace storage {
27592782
option_with_default<std::chrono::milliseconds> m_maximum_execution_time;
27602783
option_with_default<azure::storage::location_mode> m_location_mode;
27612784
option_with_default<size_t> m_http_buffer_size;
2785+
option_with_default<bool> m_validate_certificates;
27622786
};
27632787

27642788
/// <summary>

Microsoft.WindowsAzure.Storage/includes/wascore/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace azure { namespace storage { namespace protocol {
3535
const size_t default_stream_write_size = 4 * 1024 * 1024;
3636
const size_t default_stream_read_size = 4 * 1024 * 1024;
3737
const size_t default_buffer_size = 64 * 1024;
38+
const bool default_validate_certificates = true;
3839
const utility::size64_t default_single_blob_upload_threshold = 128 * 1024 * 1024;
3940
const utility::size64_t default_single_blob_download_threshold = 32 * 1024 * 1024;
4041
const utility::size64_t default_single_block_download_threshold = 4 * 1024 * 1024;

Microsoft.WindowsAzure.Storage/src/cloud_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace azure { namespace storage {
3131
WASTORAGE_API request_options::request_options()
3232
: m_location_mode(azure::storage::location_mode::primary_only), m_http_buffer_size(protocol::default_buffer_size),\
3333
m_maximum_execution_time(protocol::default_maximum_execution_time), m_server_timeout(protocol::default_server_timeout),\
34-
m_noactivity_timeout(protocol::default_noactivity_timeout)
34+
m_noactivity_timeout(protocol::default_noactivity_timeout),m_validate_certificates(protocol::default_validate_certificates)
3535
{
3636
}
3737

Microsoft.WindowsAzure.Storage/src/executor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ namespace azure { namespace storage { namespace core {
150150
}
151151
#endif
152152

153+
config.set_validate_certificates(instance->m_request_options.validate_certificates());
154+
153155
// 5-6. Potentially upload data and get response
154156
instance->assert_canceled();
155157
#ifdef _WIN32

0 commit comments

Comments
 (0)