== How to fix it in cURL

=== Code examples

The following code samples attempt to create an HTTP request.

==== Noncompliant code example

This sample uses Curl's default TLS algorithms, which are weak
cryptographical algorithms: TLSv1.0 and LTSv1.1.

[source,cpp,diff-id=11,diff-type=noncompliant]
----
#include <curl/curl.h>

void encrypt() {
    CURL *curl;
    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();                                      // Noncompliant
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");

        curl_easy_perform(curl);
    }
}
----

==== Compliant solution

[source,cpp,diff-id=11,diff-type=compliant]
----
#include <curl/curl.h>

void encrypt() {
    CURL *curl;
    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
        curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);

        curl_easy_perform(curl);
    }
}
----

=== How does this work?

include::../../common/fix/fix.adoc[]
