Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXPORTER] Add OTLP HTTP SSL support #1793

Merged
merged 90 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e3f1b17
[WIP] Implement OTLP HTTP SSL
marcalff Nov 23, 2022
236832d
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Nov 23, 2022
9f5c8aa
Format cleanup
marcalff Nov 23, 2022
82341ef
Cleanup
marcalff Nov 23, 2022
000e36d
Fixed windows build
marcalff Nov 24, 2022
29f2851
PROTOTYPE, investigating CURLOPT for SSL.
marcalff Nov 24, 2022
98cf4bb
Build cleanup
marcalff Nov 25, 2022
0a7d8a6
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Nov 25, 2022
8362479
Build cleanup
marcalff Nov 25, 2022
20d0e16
Implement CURLOPT for SSL.
marcalff Nov 25, 2022
e4afdb6
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Nov 28, 2022
41dfeb9
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Dec 1, 2022
461eec5
Work in progress
marcalff Dec 1, 2022
8c7e68e
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Dec 2, 2022
d25fae8
Work in progress
marcalff Dec 6, 2022
d5164e3
Work in progress, continued.
marcalff Dec 6, 2022
d686852
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Dec 7, 2022
cf6cb43
Used CAINFO
marcalff Dec 7, 2022
51eaad7
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Dec 7, 2022
eba3156
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Dec 11, 2022
21acc47
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Dec 13, 2022
956774a
Added doc, testing with SSL/TLS.
marcalff Dec 13, 2022
299d774
Implemented flag ssl_insecure_skip_verify.
marcalff Dec 13, 2022
d5a54fd
Format cleanup
marcalff Dec 13, 2022
e17c891
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Dec 13, 2022
1e96070
Code cleanup.
marcalff Dec 14, 2022
512e793
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Jan 2, 2023
becf5df
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Jan 4, 2023
9fc560d
Add TLS support - work in progress
marcalff Jan 4, 2023
09204ba
WIP
marcalff Jan 10, 2023
dfcd670
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Jan 16, 2023
e49eef5
SSL TLS
marcalff Jan 16, 2023
4c78897
TLS SSL, continued.
marcalff Jan 17, 2023
46c0662
WIP
marcalff Jan 17, 2023
7294163
Revert TLS 1.2 and 1.3 mix, fixed build breaks.
marcalff Jan 17, 2023
88e88e1
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Jan 17, 2023
7c3f50c
Format
marcalff Jan 17, 2023
4f301cb
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Jan 17, 2023
cb9e025
Resolved TLS 1.2 vs TLS 1.3 CIPHER.
marcalff Jan 18, 2023
cd8a172
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Jan 24, 2023
71e83c1
Implemented code review comments.
marcalff Jan 24, 2023
e0f91a0
Fixed GCC 12 warnings
marcalff Jan 24, 2023
e0bc8bb
Code cleanup for TLS version.
marcalff Jan 24, 2023
3b0663f
Code cleanup
marcalff Jan 25, 2023
3b31f96
Implemented test client (draft)
marcalff Jan 29, 2023
ab3bba8
format cleanup, maintainer build
marcalff Jan 29, 2023
1e2a610
add grpc in maintainer ci
marcalff Jan 29, 2023
2266202
CI
marcalff Jan 29, 2023
ea15e31
PROTOBUF_VERSION: 3.21.12
marcalff Jan 29, 2023
835fab4
Back to probuf 3.20.3,
marcalff Jan 29, 2023
72edc68
Do not check in cert, generate them (todo)
marcalff Jan 29, 2023
7b7009c
CI protobuf
marcalff Jan 29, 2023
05e4419
Merge branch 'open-telemetry:main' into fix_otlp_http_ssl_1402
marcalff Jan 29, 2023
beb6aa8
Protobuf tar name
marcalff Jan 29, 2023
9cc76a9
Run func test
marcalff Jan 29, 2023
f6fff95
Func test, continued.
marcalff Jan 29, 2023
65b72e3
Fix cfssl
marcalff Jan 29, 2023
25bc4f7
functional test client, continued.
marcalff Jan 30, 2023
e493ed1
Fixed build warnings.
marcalff Feb 1, 2023
8ed1403
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 1, 2023
1a26090
Integration of functional tests to CI
marcalff Feb 2, 2023
e228383
Run both sync and async functional tests, added report in CI.
marcalff Feb 2, 2023
4458dac
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 3, 2023
4074614
ASYNC tests failed,
marcalff Feb 4, 2023
62ce2e8
Implemented warnings on duration env var, when parsing failed.
marcalff Feb 8, 2023
750155e
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 8, 2023
73eca29
Fixed copyright.
marcalff Feb 8, 2023
4074120
Fixed code review comments.
marcalff Feb 9, 2023
3bc586b
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 13, 2023
34eff9e
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 13, 2023
0f17600
Code cleanup
marcalff Feb 14, 2023
4437433
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Feb 17, 2023
cb9b6eb
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Mar 3, 2023
af04e5d
WIP
marcalff Mar 3, 2023
2613c7d
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Mar 11, 2023
eb9bc19
Cleanup env var names.
marcalff Mar 11, 2023
f6d6c04
Resolved duplication of SSL options.
marcalff Mar 11, 2023
f088bbc
Code cleanup
marcalff Mar 12, 2023
dce246e
CHANGELOG
marcalff Mar 12, 2023
ba6d403
Removed notes.txt, duplicated with ssl doc.
marcalff Mar 12, 2023
659ff69
Build cleanup
marcalff Mar 12, 2023
a5e6cdf
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Mar 23, 2023
df6335e
Fixed code review comments, added _PREVIEW to feature flags.
marcalff Mar 24, 2023
663f009
Fixed warnings in maintainer mode.
marcalff Mar 24, 2023
5b529bd
Merge branch 'main' into fix_otlp_http_ssl_1402
marcalff Mar 29, 2023
eb6c362
Implemented code review comments.
marcalff Mar 30, 2023
0593b4c
Fixed http examples
marcalff Mar 30, 2023
340ac8d
Build cleanup for windows / gmock
marcalff Mar 30, 2023
c247437
Build cleanup, windows + gmock macros
marcalff Mar 30, 2023
8a47cf8
Merge branch 'main' into fix_otlp_http_ssl_1402
esigo Apr 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Increment the:

* [RESOURCE SDK] Fix schema URL precedence bug in `Resource::Merge`.
[#2036](https://github.com/open-telemetry/opentelemetry-cpp/pull/2036)
* [EXPORTER] Add OTLP HTTP SSL support
[#1793](https://github.com/open-telemetry/opentelemetry-cpp/pull/1793)

## [1.8.3] 2023-03-06

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,8 @@ struct OtlpHttpClientOptions
{
std::string url;

bool ssl_insecure_skip_verify;

std::string ssl_ca_cert_path;
std::string ssl_ca_cert_string;

std::string ssl_client_key_path;
std::string ssl_client_key_string;

std::string ssl_client_cert_path;
std::string ssl_client_cert_string;

std::string ssl_min_tls;
std::string ssl_max_tls;
std::string ssl_cipher;
std::string ssl_cipher_suite;
/** SSL options. */
ext::http::client::HttpSslOptions ssl_options;
marcalff marked this conversation as resolved.
Show resolved Hide resolved

// By default, post json data
HttpRequestContentType content_type = HttpRequestContentType::kJson;
Expand Down Expand Up @@ -115,17 +102,18 @@ struct OtlpHttpClientOptions
std::size_t input_max_requests_per_connection = 8,
nostd::string_view input_user_agent = GetOtlpDefaultUserAgent())
: url(input_url),
ssl_insecure_skip_verify(input_ssl_insecure_skip_verify),
ssl_ca_cert_path(input_ssl_ca_cert_path),
ssl_ca_cert_string(input_ssl_ca_cert_string),
ssl_client_key_path(input_ssl_client_key_path),
ssl_client_key_string(input_ssl_client_key_string),
ssl_client_cert_path(input_ssl_client_cert_path),
ssl_client_cert_string(input_ssl_client_cert_string),
ssl_min_tls(input_ssl_min_tls),
ssl_max_tls(input_ssl_max_tls),
ssl_cipher(input_ssl_cipher),
ssl_cipher_suite(input_ssl_cipher_suite),
ssl_options(input_url,
input_ssl_insecure_skip_verify,
input_ssl_ca_cert_path,
input_ssl_ca_cert_string,
input_ssl_client_key_path,
input_ssl_client_key_string,
input_ssl_client_cert_path,
input_ssl_client_cert_string,
input_ssl_min_tls,
input_ssl_max_tls,
input_ssl_cipher,
input_ssl_cipher_suite),
content_type(input_content_type),
json_bytes_mapping(input_json_bytes_mapping),
use_json_name(input_use_json_name),
Expand Down Expand Up @@ -288,9 +276,6 @@ class OtlpHttpClient
// The configuration options associated with this HTTP client.
const OtlpHttpClientOptions options_;

/** SSL options. */
ext::http::client::HttpSslOptions ssl_options_;

// Object that stores the HTTP sessions that have been created
std::shared_ptr<ext::http::client::HttpClient> http_client_;

Expand Down
52 changes: 26 additions & 26 deletions exporters/otlp/src/otlp_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,14 @@ std::string GetOtlpDefaultLogsSslClientCertificateString()

/*
EXPERIMENTAL:
Waiting on Environment variable names to be added in the spec,
see https://github.com/open-telemetry/opentelemetry-specification/pull/3088
Environment variable names do not exist in the spec,
using the OTEL_CPP_ namespace.
*/

std::string GetOtlpDefaultTracesSslTlsMinVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_TRACES_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MIN_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_TRACES_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MIN_TLS";

std::string value;
bool exists;
Expand All @@ -645,8 +645,8 @@ std::string GetOtlpDefaultTracesSslTlsMinVersion()

std::string GetOtlpDefaultMetricsSslTlsMinVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_METRICS_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MIN_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_METRICS_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MIN_TLS";

std::string value;
bool exists;
Expand All @@ -662,8 +662,8 @@ std::string GetOtlpDefaultMetricsSslTlsMinVersion()

std::string GetOtlpDefaultLogsSslTlsMinVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_LOGS_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MIN_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_LOGS_MIN_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MIN_TLS";

std::string value;
bool exists;
Expand All @@ -679,8 +679,8 @@ std::string GetOtlpDefaultLogsSslTlsMinVersion()

std::string GetOtlpDefaultTracesSslTlsMaxVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_TRACES_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MAX_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_TRACES_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MAX_TLS";

std::string value;
bool exists;
Expand All @@ -696,8 +696,8 @@ std::string GetOtlpDefaultTracesSslTlsMaxVersion()

std::string GetOtlpDefaultMetricsSslTlsMaxVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_METRICS_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MAX_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_METRICS_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MAX_TLS";

std::string value;
bool exists;
Expand All @@ -713,8 +713,8 @@ std::string GetOtlpDefaultMetricsSslTlsMaxVersion()

std::string GetOtlpDefaultLogsSslTlsMaxVersion()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_LOGS_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_MAX_TLS";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_LOGS_MAX_TLS";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_MAX_TLS";

std::string value;
bool exists;
Expand All @@ -730,8 +730,8 @@ std::string GetOtlpDefaultLogsSslTlsMaxVersion()

std::string GetOtlpDefaultTracesSslTlsCipher()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_TRACES_CIPHER";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_TRACES_CIPHER";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER";

std::string value;
bool exists;
Expand All @@ -747,8 +747,8 @@ std::string GetOtlpDefaultTracesSslTlsCipher()

std::string GetOtlpDefaultMetricsSslTlsCipher()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_METRICS_CIPHER";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_METRICS_CIPHER";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER";

std::string value;
bool exists;
Expand All @@ -764,8 +764,8 @@ std::string GetOtlpDefaultMetricsSslTlsCipher()

std::string GetOtlpDefaultLogsSslTlsCipher()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_LOGS_CIPHER";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_LOGS_CIPHER";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER";

std::string value;
bool exists;
Expand All @@ -781,8 +781,8 @@ std::string GetOtlpDefaultLogsSslTlsCipher()

std::string GetOtlpDefaultTracesSslTlsCipherSuite()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_TRACES_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER_SUITE";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_TRACES_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER_SUITE";

std::string value;
bool exists;
Expand All @@ -798,8 +798,8 @@ std::string GetOtlpDefaultTracesSslTlsCipherSuite()

std::string GetOtlpDefaultMetricsSslTlsCipherSuite()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_METRICS_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER_SUITE";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_METRICS_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER_SUITE";

std::string value;
bool exists;
Expand All @@ -815,8 +815,8 @@ std::string GetOtlpDefaultMetricsSslTlsCipherSuite()

std::string GetOtlpDefaultLogsSslTlsCipherSuite()
{
constexpr char kSignalEnv[] = "OTEL_EXPORTER_OTLP_LOGS_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_EXPORTER_OTLP_CIPHER_SUITE";
constexpr char kSignalEnv[] = "OTEL_CPP_EXPORTER_OTLP_LOGS_CIPHER_SUITE";
constexpr char kGenericEnv[] = "OTEL_CPP_EXPORTER_OTLP_CIPHER_SUITE";

std::string value;
bool exists;
Expand Down
28 changes: 2 additions & 26 deletions exporters/otlp/src/otlp_http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ OtlpHttpClient::~OtlpHttpClient()

OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options,
std::shared_ptr<ext::http::client::HttpClient> http_client)
: is_shutdown_(false), options_(options), ssl_options_(), http_client_(http_client)
: is_shutdown_(false), options_(options), http_client_(http_client)
{
http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection);
}
Expand Down Expand Up @@ -953,39 +953,15 @@ OtlpHttpClient::createSession(
return opentelemetry::sdk::common::ExportResult::kFailure;
}

// std::string starts_with is C++20
std::string candidate_scheme = options_.url.substr(0, 6);

if (candidate_scheme == "https:")
{
ssl_options_.use_ssl = true;
ssl_options_.ssl_insecure_skip_verify = options_.ssl_insecure_skip_verify;
ssl_options_.ssl_ca_cert_path = options_.ssl_ca_cert_path;
ssl_options_.ssl_ca_cert_string = options_.ssl_ca_cert_string;
ssl_options_.ssl_client_key_path = options_.ssl_client_key_path;
ssl_options_.ssl_client_key_string = options_.ssl_client_key_string;
ssl_options_.ssl_client_cert_path = options_.ssl_client_cert_path;
ssl_options_.ssl_client_cert_string = options_.ssl_client_cert_string;
ssl_options_.ssl_min_tls = options_.ssl_min_tls;
ssl_options_.ssl_max_tls = options_.ssl_max_tls;
ssl_options_.ssl_cipher = options_.ssl_cipher;
ssl_options_.ssl_cipher_suite = options_.ssl_cipher_suite;
}
else
{
ssl_options_.use_ssl = false;
}

auto session = http_client_->CreateSession(options_.url);

auto request = session->CreateRequest();

for (auto &header : options_.http_headers)
{
request->AddHeader(header.first, header.second);
}
request->SetUri(http_uri_);
request->SetSslOptions(ssl_options_);
request->SetSslOptions(options_.ssl_options);
marcalff marked this conversation as resolved.
Show resolved Hide resolved
request->SetTimeoutMs(std::chrono::duration_cast<std::chrono::milliseconds>(options_.timeout));
request->SetMethod(http_client::Method::Post);
request->SetBody(body_vec);
Expand Down
43 changes: 0 additions & 43 deletions exporters/zipkin/test/zipkin_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,52 +112,11 @@ class IsValidMessageMatcher
std::string trace_id_;
};

// FIXME: Use in OTLP tests

class IsValidSslOptionsMatcher
{
public:
IsValidSslOptionsMatcher(const ext::http::client::HttpSslOptions &ssl_options)
: ssl_options_(ssl_options)
{}
bool MatchAndExplain(const ext::http::client::HttpSslOptions &opt,
MatchResultListener * /* listener */) const
{
bool use_match = (ssl_options_.use_ssl == opt.use_ssl);

if (!ssl_options_.use_ssl)
{
return use_match;
}

return (use_match && (opt.ssl_insecure_skip_verify == ssl_options_.ssl_insecure_skip_verify) &&
(opt.ssl_ca_cert_path == ssl_options_.ssl_ca_cert_path) &&
(opt.ssl_ca_cert_string == ssl_options_.ssl_ca_cert_string) &&
(opt.ssl_client_key_path == ssl_options_.ssl_client_key_path) &&
(opt.ssl_client_key_string == ssl_options_.ssl_client_key_string) &&
(opt.ssl_client_cert_path == ssl_options_.ssl_client_cert_path) &&
(opt.ssl_client_cert_string == ssl_options_.ssl_client_cert_string));
}

void DescribeTo(std::ostream *os) const { *os << "ssl_options matches"; }

void DescribeNegationTo(std::ostream *os) const { *os << "ssl_options does not matche"; }

private:
ext::http::client::HttpSslOptions ssl_options_;
};

PolymorphicMatcher<IsValidMessageMatcher> IsValidMessage(const std::string &trace_id)
{
return MakePolymorphicMatcher(IsValidMessageMatcher(trace_id));
}

PolymorphicMatcher<IsValidSslOptionsMatcher> IsValidSslOptions(
const ext::http::client::HttpSslOptions &ssl_options)
{
return MakePolymorphicMatcher(IsValidSslOptionsMatcher(ssl_options));
}

// Create spans, let processor call Export()
TEST_F(ZipkinExporterTestPeer, ExportJsonIntegrationTest)
{
Expand Down Expand Up @@ -207,9 +166,7 @@ TEST_F(ZipkinExporterTestPeer, ExportJsonIntegrationTest)
report_trace_id.assign(trace_id_hex, sizeof(trace_id_hex));

auto expected_url = nostd::string_view{"http://localhost:9411/api/v2/spans"};

EXPECT_CALL(*mock_http_client, Post(expected_url, IsValidMessage(report_trace_id), _))

.Times(Exactly(1))
.WillOnce(Return(ByMove(ext::http::client::Result{
std::unique_ptr<ext::http::client::Response>{new ext::http::client::curl::Response()},
Expand Down
35 changes: 35 additions & 0 deletions ext/include/opentelemetry/ext/http/client/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstring>
#include <map>
#include <string>
#include <vector>
Expand Down Expand Up @@ -111,6 +112,40 @@ using Headers = std::multimap<std::string, std::string, cmp_ic>;

struct HttpSslOptions
{
HttpSslOptions() {}

HttpSslOptions(nostd::string_view url,
bool input_ssl_insecure_skip_verify,
nostd::string_view input_ssl_ca_cert_path,
nostd::string_view input_ssl_ca_cert_string,
nostd::string_view input_ssl_client_key_path,
nostd::string_view input_ssl_client_key_string,
nostd::string_view input_ssl_client_cert_path,
nostd::string_view input_ssl_client_cert_string,
nostd::string_view input_ssl_min_tls,
nostd::string_view input_ssl_max_tls,
nostd::string_view input_ssl_cipher,
nostd::string_view input_ssl_cipher_suite)
: use_ssl(false),
ssl_insecure_skip_verify(input_ssl_insecure_skip_verify),
ssl_ca_cert_path(input_ssl_ca_cert_path),
ssl_ca_cert_string(input_ssl_ca_cert_string),
ssl_client_key_path(input_ssl_client_key_path),
ssl_client_key_string(input_ssl_client_key_string),
ssl_client_cert_path(input_ssl_client_cert_path),
ssl_client_cert_string(input_ssl_client_cert_string),
ssl_min_tls(input_ssl_min_tls),
ssl_max_tls(input_ssl_max_tls),
ssl_cipher(input_ssl_cipher),
ssl_cipher_suite(input_ssl_cipher_suite)
{
/* Use SSL if url starts with "https:" */
if (strncmp(url.data(), "https:", 6) == 0)
{
use_ssl = true;
}
}

/**
Use HTTPS (true) or HTTP (false).
*/
Expand Down
Loading