aws / aws-sdk-cpp

AWS SDK for C++
Apache License 2.0
1.91k stars 1.04k forks source link

fatal error: CommonCrypto/CommonDigest.h: No such file or directory #2966

Closed disa6302 closed 1 month ago

disa6302 commented 1 month ago

Describe the bug

I am using this SDK as a dependency (ExternalProject) in my project and when I run the build on Mac, everything works fine (since this library is available on Mac). However on Ubuntu 22.04 EC2 instance, it fails with the error in the description. I have already installed libcurl and openssl on the EC2 instance and USE_OPENSSL is ON by default as per the docs. I could not find anything specific to getting the build running on Linux apart from the libcurl/openssl installation requirement.

Expected Behavior

Build should succeed on the ubuntu EC2 instance.

Current Behavior

Build fails with the error in the description

Reproduction Steps

cmake_minimum_required(VERSION 3.6.3)
project(libawscpp-download NONE)
include(ExternalProject)

ExternalProject_Add(libawscpp-download
    GIT_REPOSITORY    https://github.com/aws/aws-sdk-cpp.git
    GIT_TAG           1.11.143
    LIST_SEPARATOR    "|"
    CMAKE_ARGS       -DBUILD_SHARED_LIBS=OFF
                     -DENABLE_TESTING=OFF
                     -DBUILD_ONLY=${BUILD_ONLY}
                     -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
                     -DCUSTOM_MEMORY_MANAGEMENT=OFF
    BUILD_ALWAYS      TRUE
    TEST_COMMAND      ""
)

Possible Solution

N/A

Additional Information/Context

No response

AWS CPP SDK version used

1.11.143

Compiler and Version used

11.4.0

Operating System and version

Ubuntu 22.04 EC2 instance

disa6302 commented 1 month ago

Setting -DTARGET_ARCH value to LINUX fixed the issue. If this is a mandatory requirement to set TARGET_ARCH, I think it should be called out in the docs, unless I am missing something here and there is another reason my build fails without setting this option?

DmitriyMusatkin commented 1 month ago

How are you getting project over to your EC2 instance? CommonCrypto is a mac library and would not be present on linux, so sounds like somehow project on ec2 instance is getting configured for mac

disa6302 commented 1 month ago

My project is on github and I am doing a traditional git clone on the EC2 and building the project. I am including this repo as a dependency as I mentioned previously. So, very standard.

DmitriyMusatkin commented 1 month ago

I will need more exact repro steps than attached.

On a clean ubuntu instance the cmake you attached builds core (where that crypto header is used) just fine.

[ 40%] Linking CXX static library libaws-cpp-sdk-core.a [ 40%] Built target aws-cpp-sdk-core

Somehow you build is detecting target as mac.

disa6302 commented 1 month ago

@DmitriyMusatkin ,

I dont think the issue lies in building this SDK standalone. It lies more in integrating in another project. You can look at this cmake file here: https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/simplify-sample/CMakeLists.txt#L255-L261. These are the exact lines that build the aws sdk cpp. This is the dependency file: https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/simplify-sample/CMake/Dependencies/libawscpp-CMakeLists.txt

I am not sure what information I can provide here, let me know if this still does not help. But, the cmake file does not set up any platform at all. So, not sure how the SDK is detecting mac.

On another note, I have a generic question: does this SDK support openssl 3.x? I am running into a segfault when I run my application. Wanted to get general guidance on causes of this issue. Here is the stack trace:

(gdb) bt
#0  0x0000555555933ef4 in EC_GROUP_order_bits ()
#1  0x00007ffff6d6abed in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.3
#2  0x00007ffff6d70f4b in ENGINE_init () from /lib/x86_64-linux-gnu/libcrypto.so.3
#3  0x00007ffff6da7461 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.3
#4  0x00007ffff71963d3 in SSL_CTX_new_ex () from /lib/x86_64-linux-gnu/libssl.so.3
#5  0x00007ffff7e24167 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#6  0x00007ffff7e2a3a7 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#7  0x00007ffff7e26c9b in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#8  0x00007ffff7ddf026 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#9  0x00007ffff7df8e86 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#10 0x00007ffff7dfb37e in curl_multi_perform () from /lib/x86_64-linux-gnu/libcurl.so.4
#11 0x00007ffff7dd7eb3 in curl_easy_perform () from /lib/x86_64-linux-gnu/libcurl.so.4
#12 0x00005555557d58e1 in Aws::Http::CurlHttpClient::MakeRequest(std::shared_ptr<Aws::Http::HttpRequest> const&, Aws::Utils::RateLimits::RateLimiterInterface*, Aws::Utils::RateLimits::RateLimiterInterface*) const
    ()
#13 0x0000555555746a6b in std::_Function_handler<std::shared_ptr<Aws::Http::HttpResponse> (), Aws::Client::AWSClient::AttemptOneRequest(std::shared_ptr<Aws::Http::HttpRequest> const&, Aws::AmazonWebServiceRequest const&, char const*, char const*, char const*) const::{lambda()#3}>::_M_invoke(std::_Any_data const&) ()
#14 0x00005555557b1cab in std::shared_ptr<Aws::Http::HttpResponse> smithy::components::tracing::TracingUtils::MakeCallWithTiming<std::shared_ptr<Aws::Http::HttpResponse> >(std::function<std::shared_ptr<Aws::Http::HttpResponse> ()>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, smithy::components::tracing::Meter const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#15 0x000055555578d61e in Aws::Client::AWSClient::AttemptOneRequest(std::shared_ptr<Aws::Http::HttpRequest> const&, Aws::AmazonWebServiceRequest const&, char const*, char const*, char const*) const ()
#16 0x0000555555797fcd in Aws::Client::AWSClient::AttemptExhaustively(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const ()
#17 0x000055555579b95f in Aws::Client::AWSJsonClient::MakeRequest(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const ()
#18 0x000055555579c318 in Aws::Client::AWSJsonClient::MakeRequest(Aws::AmazonWebServiceRequest const&, Aws::Endpoint::AWSEndpoint const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const ()
#19 0x00005555556ebc8b in Aws::CloudWatchLogs::CloudWatchLogsClient::CreateLogGroup(Aws::CloudWatchLogs::Model::CreateLogGroupRequest const&) const::{lambda()#1}::operator()() const ()
#20 0x00005555556ebda5 in std::_Function_handler<Aws::Utils::Outcome<Aws::NoResult, Aws::CloudWatchLogs::CloudWatchLogsError> (), Aws::CloudWatchLogs::CloudWatchLogsClient::CreateLogGroup(Aws::CloudWatchLogs::Model::CreateLogGroupRequest const&) const::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
#21 0x000055555573cbff in Aws::Utils::Outcome<Aws::NoResult, Aws::CloudWatchLogs::CloudWatchLogsError> smithy::components::tracing::TracingUtils::MakeCallWithTiming<Aws::Utils::Outcome<Aws::NoResult, Aws::CloudWatchLogs::CloudWatchLogsError> >(std::function<Aws::Utils::Outcome<Aws::NoResult, Aws::CloudWatchLogs::CloudWatchLogsError> ()>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, smithy::components::tracing::Meter const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#22 0x00005555556fbc43 in Aws::CloudWatchLogs::CloudWatchLogsClient::CreateLogGroup(Aws::CloudWatchLogs::Model::CreateLogGroupRequest const&) const ()
#23 0x000055555561f519 in CppInteg::CloudwatchLogs::init (this=0x555555d1aca0 <CppInteg::Cloudwatch::getInstanceImpl(Aws::Client::ClientConfiguration*)::instance>,
    channelName=0x7fffffffe0d0 "DEFAULT-WebrtcPeriodicOpenSSL", region=0x555555ad51c7 "us-west-2", isMaster=1) at /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/cloudwatch-integ/CloudwatchLogs.cpp:28
#24 0x000055555561ae1d in CppInteg::Cloudwatch::init (channelName=0x7fffffffe0d0 "DEFAULT-WebrtcPeriodicOpenSSL", region=0x555555ad51c7 "us-west-2", isMaster=1)
    at /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/cloudwatch-integ/Cloudwatch.cpp:23
#25 0x000055555562f823 in main (argc=1, argv=0x7fffffffe308) at /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/cloudwatch-integ/kvsWebRTCClientMasterCloudwatch.cpp:251

The error happens when I try to use CreateLogGroup as part of CloudwatchLogs. I can provide some snippets if this is an issue which you have not noticed before or if there is not a generic suggestion to fix this issue.

Just adding my minimum sample here for repro:

int main(int argc, char* argv[])
{
    char* region;
    Aws::SDKOptions options;
    Aws::InitAPI(options);
    {
          if ((region = GETENV(DEFAULT_REGION_ENV_VAR)) == NULL) {
               region = (PCHAR) DEFAULT_AWS_REGION;
          }
          CppInteg::Cloudwatch::init(channelName, region, TRUE);
    }
}

Cloudwatch.cpp:

Cloudwatch::Cloudwatch(ClientConfiguration* pClientConfig)
    : logs(pClientConfig), monitoring(pClientConfig), terminated(FALSE)
{
}

void Cloudwatch::init(char* channelName, char* region, bool isMaster)
{
    ClientConfiguration clientConfig;
    CreateLogGroupRequest createLogGroupRequest;
    Aws::CloudWatchLogs::Model::CreateLogStreamOutcome createLogStreamOutcome;
    CreateLogStreamRequest createLogStreamRequest;

    clientConfig.region = region;
    auto& instance = getInstanceImpl(&clientConfig);

    if (STATUS_FAILED(instance.logs.init(channelName, region, isMaster))) {
        DLOGW("Failed to create Cloudwatch logger, fallback to file logger");
    } else {
        globalCustomLogPrintFn = logger;
    }
    instance.monitoring.init(channelName, region, isMaster));
}

Cloudwatch& Cloudwatch::getInstance()
{
    return getInstanceImpl();
}

Cloudwatch& Cloudwatch::getInstanceImpl(ClientConfiguration* pClientConfig)
{
    static Cloudwatch instance{pClientConfig};
    return instance;
}

logs.init implementation:

STATUS CloudwatchLogs::init(char* channelName, char* region, bool isMaster)
{
    STATUS retStatus = STATUS_SUCCESS;
    CreateLogGroupRequest createLogGroupRequest;
    Aws::CloudWatchLogs::Model::CreateLogStreamOutcome createLogStreamOutcome;
    CreateLogStreamRequest createLogStreamRequest;
    std::stringstream defaultLogStreamName;
    defaultLogStreamName << channelName << '-' << (isMaster ? "master" : "viewer") << '-'
                         << GETTIME() / HUNDREDS_OF_NANOS_IN_A_MILLISECOND;

    this->logStreamName = defaultLogStreamName.str();
    this->logGroupName = LOG_GROUP_NAME;

    DLOGI("Log stream name: %s", this->logStreamName.c_str());

    createLogGroupRequest.SetLogGroupName(LOG_GROUP_NAME);
    this->client.CreateLogGroup(createLogGroupRequest); ----> this is where it seems to crash.

    createLogStreamRequest.SetLogGroupName(LOG_GROUP_NAME);
    createLogStreamRequest.SetLogStreamName(this->logStreamName);
    createLogStreamOutcome = this->client.CreateLogStream(createLogStreamRequest);

    CHK_ERR(createLogStreamOutcome.IsSuccess(), STATUS_INVALID_OPERATION, "Failed to create \"%s\" log stream: %s",
            this->logStreamName.c_str(), createLogStreamOutcome.GetError().GetMessage().c_str());

CleanUp:

    return retStatus;
}

I had a Q&A opened earlier, but I never got a response there. https://github.com/aws/aws-sdk-cpp/discussions/2801. Also this issue is specific to ubuntu, does not happen on Mac.

disa6302 commented 1 month ago

Another data point. I went back all the way to 1.9.67 and ran the same app and it runs fine without crashing.

DmitriyMusatkin commented 1 month ago

from quick your CMakeLists looks fine, but someone would need to debug through whats going on with it and why it ends up thinking target is mac. Ideally, we would need a small repro to figure out whats going on.

And yes, CPP SDK supports Openssl3. Your stack trace looks like a classic case of 2 different libcryptos being compiled into one binary. CPP SDK switched to using aws-lc by default in 1.11, so you would want to specify USE_OPENSSL to build against openssl. In addition you would want to confirm that nothing else is using some other crypto

disa6302 commented 1 month ago

Oh got it. The documentation says USE_OPENSSL is ON by default. https://github.com/aws/aws-sdk-cpp/blob/1.11.143/docs/CMake_Parameters.md#use_openssl

Might want to fix that or reword to avoid confusion. Also, I just set USE_OPENSSL to ON. I still see the same issue. However, the strange thing is, in the build output, I do see that aws sdk is using the openssl version 1.x that I am installing from source in my project. I also have libcurl4-openssl installed on ubuntu because this repo requires curl, but given aws-sdk is finding the openssl version installed from source in my project, i am unsure where I am going wrong. Any pointers I can follow to debug this? Also, what changed between 1.9.67 and 1.11.143? Because the exact same code runs just fine with 1.9.67 (assuming it is using openssl by default, but I have curl system installed and openssl installed from source in my project).

but someone would need to debug through whats going on with it and why it ends up thinking target is mac.

Got it. I will see what I can do for this.

DmitriyMusatkin commented 1 month ago

Ignore my comment, im mixing up my defaults between CPP SDK and CRT. CPP SDK does default to have USE_OPENSSL on, so it should build against openssl. Which openssl it will build against is the tricky part. And that where there could be a lot of corner cases:

To debug this you would need to look at which exact version of openssl all your deps are using

disa6302 commented 1 month ago
[ 22%] Performing download step (git clone) for 'libawscpp-download'
Cloning into 'libawscpp-download'...
Updating files: 100% (121947/121947), done.
Note: switching to '1.11.143'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at a5cb9a29a8 Doc-only update to incorporate several doc bug fixes This release updates the Custom Vocabulary Weight field to support a value of 0.
Submodule 'aws-common-runtime/aws-crt-cpp' (https://github.com/awslabs/aws-crt-cpp.git) registered for path 'crt/aws-crt-cpp'
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp'...
Submodule path 'crt/aws-crt-cpp': checked out '363d09e8a3509f663327d6e8414d0b2e052c815d'
Submodule 'crt/aws-c-auth' (https://github.com/awslabs/aws-c-auth.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-auth'
Submodule 'crt/aws-c-cal' (https://github.com/awslabs/aws-c-cal.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-cal'
Submodule 'crt/aws-c-common' (https://github.com/awslabs/aws-c-common.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-common'
Submodule 'crt/aws-c-compression' (https://github.com/awslabs/aws-c-compression.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-compression'
Submodule 'crt/aws-c-event-stream' (https://github.com/awslabs/aws-c-event-stream.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-event-stream'
Submodule 'crt/aws-c-http' (https://github.com/awslabs/aws-c-http.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-http'
Submodule 'crt/aws-c-io' (https://github.com/awslabs/aws-c-io.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-io'
Submodule 'crt/aws-c-mqtt' (https://github.com/awslabs/aws-c-mqtt.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-mqtt'
Submodule 'crt/aws-c-s3' (https://github.com/awslabs/aws-c-s3.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-s3'
Submodule 'crt/aws-c-sdkutils' (https://github.com/awslabs/aws-c-sdkutils.git) registered for path 'crt/aws-crt-cpp/crt/aws-c-sdkutils'
Submodule 'crt/aws-checksums' (https://github.com/awslabs/aws-checksums.git) registered for path 'crt/aws-crt-cpp/crt/aws-checksums'
Submodule 'crt/aws-lc' (https://github.com/awslabs/aws-lc.git) registered for path 'crt/aws-crt-cpp/crt/aws-lc'
Submodule 'crt/s2n' (https://github.com/awslabs/s2n.git) registered for path 'crt/aws-crt-cpp/crt/s2n'
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-auth'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-cal'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-common'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-compression'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-event-stream'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-http'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-io'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-mqtt'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-s3'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-c-sdkutils'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-checksums'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/aws-lc'...
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/s2n'...
Submodule path 'crt/aws-crt-cpp/crt/aws-c-auth': checked out 'df82232dbc9839a8b3f3b3dbb88252d23aadb614'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-cal': checked out '29578cdcb3c046efc6680f6baea572dec9bdbc2e'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-common': checked out '5c736d5c39a7e7ce8b5feb88d051084b41a8c7ea'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-compression': checked out '99ec79ee2970f1a045d4ced1501b97ee521f2f85'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-event-stream': checked out 'ec1716c726babd1381560aa8d28941fffc987394'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-http': checked out 'f800427e2e2878cf8b36f602583758769a7b3b4a'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-io': checked out 'a3555c86bd10149a1ab0c1b2810756ec54cfbe3a'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-mqtt': checked out 'a2ee9a321fcafa19b0473b88a54e0ae8dde5fddf'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-s3': checked out '231188147a8c08c9ed709100a2380be42bad6350'
Submodule path 'crt/aws-crt-cpp/crt/aws-c-sdkutils': checked out 'df511a1f2518279eb5721ab5fca6bc816efc6b32'
Submodule path 'crt/aws-crt-cpp/crt/aws-checksums': checked out '321b805559c8e911be5bddba13fcbd222a3e2d3a'
Submodule path 'crt/aws-crt-cpp/crt/aws-lc': checked out '1dd5cf92e96edd4092bc307b14969dae5eaaa507'
Submodule path 'crt/aws-crt-cpp/crt/s2n': checked out 'de987864288ce361707774e5af17d0458966c898'
Submodule 'tests/cbmc/aws-verification-model-for-libcrypto' (https://github.com/awslabs/aws-verification-model-for-libcrypto.git) registered for path 'crt/aws-crt-cpp/crt/s2n/tests/cbmc/aws-verification-model-for-libcrypto'
Cloning into '/home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/libawscpp/libawscpp-download-prefix/src/libawscpp-download/crt/aws-crt-cpp/crt/s2n/tests/cbmc/aws-verification-model-for-libcrypto'...
Submodule path 'crt/aws-crt-cpp/crt/s2n/tests/cbmc/aws-verification-model-for-libcrypto': checked out '440a07ca02d60ff8158cb99fb89833de35d76ae6'
[ 33%] No patch step for 'libawscpp-download'
[ 44%] Performing update step for 'libawscpp-download'
[ 55%] Performing configure step for 'libawscpp-download'
CMake Warning at CMakeLists.txt:9 (message):
  In 1.11 releases, we are releasing experimental alternative building
  mode.By setting -DLEGACY_MODE=OFF you can test our advances in modern CMake
  building and provide early feedback.  The legacy support is set by default
  in 1.11, when you complete build updating scripts please update the build
  flags as mentioned in README.md and set -DLEGACY_BUILD=OFF.  The legacy
  support will be removed at 1.12.0 release.

-- TARGET_ARCH not specified; inferring host OS to be platform compilation target
-- Building AWS libraries as static objects
-- Generating linux build config
-- Building project version: 1.11.143
-- The CXX compiler identification is GNU 11.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3.10 (found version "3.10.12")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
--   Zlib library: /usr/lib/x86_64-linux-gnu/libz.so
-- Encryption: LibCrypto
-- Found crypto: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a
-- LibCrypto Include Dir: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include
-- LibCrypto Shared Lib:  /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.so
-- LibCrypto Static Lib:  /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Http client: Curl
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.81.0")
--   Curl include directory: /usr/include/x86_64-linux-gnu
--   Curl library: /usr/lib/x86_64-linux-gnu/libcurl.so
-- Performing Test HAVE_ATOMICS_WITHOUT_LIBATOMIC
-- Performing Test HAVE_ATOMICS_WITHOUT_LIBATOMIC - Success
-- AWS CRT C++ 0.23.0
-- The C compiler identification is GNU 11.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (dev) at crt/aws-crt-cpp/crt/aws-c-common/CMakeLists.txt:5 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'STATIC_CRT'.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- CMake 3.15.2
-- Performing Test AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS
-- Performing Test AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS - Success
-- Performing Test AWS_HAVE_WINAPI_DESKTOP
-- Performing Test AWS_HAVE_WINAPI_DESKTOP - Failed
-- Performing Test AWS_ARCH_INTEL
-- Performing Test AWS_ARCH_INTEL - Success
-- Performing Test AWS_ARCH_ARM64
-- Performing Test AWS_ARCH_ARM64 - Failed
-- Performing Test AWS_ARCH_ARM32
-- Performing Test AWS_ARCH_ARM32 - Failed
-- Performing Test AWS_HAVE_GCC_INLINE_ASM
-- Performing Test AWS_HAVE_GCC_INLINE_ASM - Success
-- Performing Test AWS_HAVE_AUXV
-- Performing Test AWS_HAVE_AUXV - Success
-- Performing Test AWS_HAVE_EXECINFO
-- Performing Test AWS_HAVE_EXECINFO - Success
-- Performing Test AWS_HAVE_LINUX_IF_LINK_H
-- Performing Test AWS_HAVE_LINUX_IF_LINK_H - Success
-- Performing Test HAVE_M_AVX2_FLAG
-- Performing Test HAVE_M_AVX2_FLAG - Success
-- Performing Test HAVE_AVX2_INTRINSICS
-- Performing Test HAVE_AVX2_INTRINSICS - Success
-- Performing Test HAVE_MM256_EXTRACT_EPI64
-- Performing Test HAVE_MM256_EXTRACT_EPI64 - Success
-- Looking for pthread_mutexattr_init
-- Looking for pthread_mutexattr_init - not found
-- Performing Test HAS_FPIC_FLAG
-- Performing Test HAS_FPIC_FLAG - Success
-- Performing Test HAS_64BIT_FILE_OFFSET_BY_DEFAULT
-- Performing Test HAS_64BIT_FILE_OFFSET_BY_DEFAULT - Success
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Performing Test HAS_WGNU
-- Performing Test HAS_WGNU - Failed
-- Performing Test HAVE_SYSCONF
-- Performing Test HAVE_SYSCONF - Success
-- Looking for pthread_attr_setaffinity_np
-- Looking for pthread_attr_setaffinity_np - found
-- Performing Test PTHREAD_SETNAME_TAKES_2ARGS
-- Performing Test PTHREAD_SETNAME_TAKES_2ARGS - Success
-- Performing Test PTHREAD_GETNAME_TAKES_2ARGS
-- Performing Test PTHREAD_GETNAME_TAKES_2ARGS - Failed
-- Performing Test PTHREAD_GET_NAME_TAKES_2ARGS
-- Performing Test PTHREAD_GET_NAME_TAKES_2ARGS - Failed
-- Performing Test PTHREAD_GETNAME_TAKES_3ARGS
-- Performing Test PTHREAD_GETNAME_TAKES_3ARGS - Success
-- Building SIMD base64 decoder
-- Packaging currently only supported on Fedora.
-- Detected CMAKE_SYSTEM_PROCESSOR as x86_64
-- Detected 64-Bit system
-- S2N found target: AWS::crypto
-- crypto Include Dir: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include
-- Using libcrypto from the cmake path
-- CMAKE_AR found: /usr/bin/ar
-- CMAKE_RANLIB found: /usr/bin/ranlib
-- CMAKE_OBJCOPY found: /usr/bin/objcopy
-- feature S2N_ATOMIC_SUPPORTED: TRUE
-- feature S2N_CLONE_SUPPORTED: TRUE
-- feature S2N_CPUID_AVAILABLE: TRUE
-- feature S2N_DIAGNOSTICS_POP_SUPPORTED: TRUE
-- feature S2N_DIAGNOSTICS_PUSH_SUPPORTED: TRUE
-- feature S2N_EXECINFO_AVAILABLE: TRUE
-- feature S2N_FALL_THROUGH_SUPPORTED: TRUE
-- feature S2N_FEATURES_AVAILABLE: TRUE
-- feature S2N_KYBER512R3_AVX2_BMI2_SUPPORTED: TRUE
-- feature S2N_KYBER512R3_M256_INTRINSICS_SUPPORTED: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_MD5_SHA1_HASH: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_MD_CTX_SET_PKEY_CTX: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_EVP_RC4: TRUE
-- feature S2N_LIBCRYPTO_SUPPORTS_HKDF: FALSE
-- feature S2N_LIBCRYPTO_SUPPORTS_KYBER: FALSE
-- feature S2N_MADVISE_SUPPORTED: TRUE
-- feature S2N_MINHERIT_SUPPORTED: FALSE
-- feature S2N___RESTRICT__SUPPORTED: TRUE
-- feature S2N_STACKTRACE: TRUE
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- feature S2N_KYBER512R3_AVX2_BMI2: TRUE
-- Found OpenSSL: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.so (found version "1.1.1t")
-- Using libcrypto from system: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.so
-- Add s3-crt:s3 to C2J_SPECIAL_NAME_LIST
-- Considering monitoring
-- Considering logs
-- Looking for pathconf
-- Looking for pathconf - found
-- Looking for umask
-- Looking for umask - found
-- Adding monitoring to SDK build
-- Adding logs to SDK build
-- Adding core to SDK build
-- Updating version info to 1.11.143
-- Custom memory management disabled
-- Performing Test CURL_HAS_H2
-- Performing Test CURL_HAS_H2 - Success
-- Performing Test CURL_HAS_TLS_PROXY
-- Performing Test CURL_HAS_TLS_PROXY - Success
-- SKIPPING:Threads::Threads

Just adding this for your reference. Notice:

-- Found crypto: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a
-- LibCrypto Include Dir: /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include
-- LibCrypto Shared Lib:  /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.so
-- LibCrypto Static Lib:  /home/ubuntu/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Http client: Curl
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.81.0")
--   Curl include directory: /usr/include/x86_64-linux-gnu
--   Curl library: /usr/lib/x86_64-linux-gnu/libcurl.so

The AWS SDK is linking to system curl (which probably has openssl 3.x) but using the libcrypto generated from source. So if I want to use my openssl version, I might have to install curl too from source?

Could you clarify what is the difference in the crypto set up between 1.9.x and 1.11.x? Maybe that will help me in seeing what I can do to get this integration to work.

disa6302 commented 1 month ago

Update: interestingly, setting BUILD_SHARED_LIBS to ON seems to have fixed it. Any guesses on why shared vs static would lead to a different behavior in this case?

DmitriyMusatkin commented 1 month ago

CPP sdk is finding 1.1.1t on the build path, so if curl is compiled against 3.0, it will probably not work as those 2 are not abi compatible.

1.11.x did fix several bugs around how CPP SDK was trying to resolve where to find libcrypto. 1.9 might be resolving a different path for libcrypto in your case and thats why it works. Hard to tell what exact difference might be as, there are over 2 years of diffs between the 2.

CPP SDK will do a static build against openssl by default, so it will bring in openssl 1.1.1 symbols into the process first and then curl will load later and will crash when it sees openssl symbols already loaded that do not match the openssl version it was compiled against. BUILD_SHARED_LIBS probably works because in that case cpp sdk is still compiled against 1.1.1, but linking is done at runtime and it find openssl 3 in its runtime closure, which mostly works with openssl 1.1.1 headers. You can experiment with building only openssl in shared mode and everything else in static mode. But i would recommend figuring out how to get everything to use same openssl version

disa6302 commented 1 month ago

Got it. Thank you for the details! This was helpful!

jmklix commented 1 month ago

@disa6302 did you have any other questions about how to build this sdk?

disa6302 commented 1 month ago

Not at the moment. All answered. Thanks!

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.