== How to fix it in cURL

=== Code examples

include::../../common/fix/code-rationale.adoc[]

:cert_variable_name: CURLOPT_SSL_VERIFYPEER
:cert_variable_unsafe_value: 0L
:cert_variable_safe_value: 1L

include::../../common/fix/code-rationale-setting.adoc[]

==== Noncompliant code example

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

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

    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); // Noncompliant

    curl_easy_perform(curl);
}
----

==== Compliant solution

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

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

    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);

    curl_easy_perform(curl);
}
----

=== How does this work?

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