Skip to content

Instantly share code, notes, and snippets.

@jnoxon
Created January 9, 2017 18:48
Show Gist options
  • Save jnoxon/d58162dbcba4e39a4b74ec1fec0b4d7d to your computer and use it in GitHub Desktop.
Save jnoxon/d58162dbcba4e39a4b74ec1fec0b4d7d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <aws/core/Aws.h>
using namespace std;
void openssl_status(const char *msg)
{
const int bufsize = 1024*1024;
auto buf = new unsigned char[bufsize]();
cout << msg << "\n";
cout << "openssl locking callback is " << (CRYPTO_get_locking_callback() ? "ENABLED" : "DISABLED") << "\n";
cout << "openssl id callback is " << (CRYPTO_get_id_callback() ? "ENABLED" : "DISABLED") << "\n";
cout << "Testing OpenSSL, should not crash...";
int r = RAND_pseudo_bytes(buf, bufsize);
cout << "ok\n\n";
delete buf;
}
int main(void)
{
openssl_status("Nothing initialized yet (expect all DISABLED)");
Aws::SDKOptions options;
Aws::InitAPI(options);
openssl_status("AWS SDK is initialized (expect all ENABLED)");
Aws::ShutdownAPI(options);
#ifdef WORKAROUND
CRYPTO_set_locking_callback(NULL);
#endif
openssl_status("AWS SDK has been shut down (expect all DISABLED)");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment