Histórico de mensagens sobre Skip-mTLS em pix

EXIBINDO CONVERSAS RECENTES:

Texto: Skip-mTLS
Canal: pix
Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Bom dia, @vinicio254! Tudo bem?

Você pode usar o exemplo abaixo para registrar o webhook. Sobre a configuração do mTLS, você pode conferir este vídeo que ensina a configuração em servidor Apache.

php

$homolog = true; // false para produção

$config = [
"certificado" => realpath(__DIR__ . "/certificado.pem"), // certificado em .pem de produção ou homologação
"client_id" => "Client_Id",
"client_secret" => "Client_Secret"
];

$chavePix = "suachavepix";

$webhookUrl = "https://seudominio.com.br/webhook/hash=hashdeseguranca&ignorar="

$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $homolog ? "https://pix-h.api.efipay.com.br/oauth/token" : "https://pix.api.efipay.com.br/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 8,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"grant_type": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));
var_dump(curl_exec($curl));
$returnAuth = json_decode(curl_exec($curl), true);
$access_token = $returnAuth['access_token'];
curl_close($curl);


//Criação da cobrança
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $homolog ? "https://pix-h.api.efipay.com.br/v2/webhook/$chavePix" : "https://pix.api.efipay.com.br/v2/webhook/$chavePix"
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{
"webhookUrl": $webhookUrl
}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $access_token",
"x-skip-mtls-checking: true",
"Content-Type: application/json"
),
));
$responsePix = json_decode(curl_exec($curl), true);
curl_close($curl);

echo '
' . json_encode($responsePix, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '
';

Avatar discord do usuario rubenskuhl

rubenskuhl

Ver Respostas

Dúvidas de cPanel e Hosting, não específicas de API Pix, talvez possam ter solução em fóruns de hosting como o https://portaldohost.com.br/

Acho que vale ir em paralelo com a implementação e se livrar do Skip-mTLS.

Avatar discord do usuario robson_g

robson_g

Ver Respostas

Boa tarde, tudo bem?
estou com problema no Webhook, não consegui colocar o VirtualHosts no Cpanel, fiz de tudo que eu sabia, hehehe
Configurei o Apache pelo Post VirtualHosts Includes, Pre VirtualHosts Includes, com e sem Alias,
resolvi fazer com o Skip-mTLS ele registrou a webhook tudo ok, mas quando crio uma cobrança com menos de 10,00 ela cria tudo certo, mas não recebo o webhook, nem em produção nem homologação.
depois de uns 5 segundos eu consulto a cobrança e ela já está concluída, mas não recebo o webhook
configurei o hmac= tbém no webhook

Avatar discord do usuario jessica_efi

jessica_efi

Ver Respostas

Consegue. Em nossa documentação na seção Skip-mTLS, você encontra essa informação.

Avatar discord do usuario _acb09

_acb09

Ver Respostas

{
"certificate": "CAMINHO_ABSOLUTO/web\\certificates\\efipay\\homologacao-544374-cert.pem",
"clientId": "Client_Id_????",
"clientSecret": "Client_Secret_???",
"debug": false,
"pwdCertificate": "",
"responseHeaders": true,
"sandbox": true,
"timeout": 30,
"headers": {
"x-skip-mtls-checking": true
}
}

Avatar discord do usuario _acb09

_acb09

Ver Respostas

Boa tarde!
Estou recebendo o seguinte erro ao criar um webhook de pix:

{
"code": 400,
"error": "json_invalido",
"errorDescription": "Parâmetro \".headers['x-skip-mtls-checking']\", deve ser igual a um dos valores predefinidos"
}

Estou usando o SDK, e todos endpoints funcionam (cartão, pix e boleto) porém não consigo gerar o webhook. Ou recebo o erro acima, ou recebo Curl 52 Error.

Avatar discord do usuario felipenunes0714

felipenunes0714

400
json_invalido
Parâmetro ".headers['x-skip-mtls-checking']", deve ser igual a um dos valores predefinidos


$options["headers"] = [
"x-skip-mtls-checking" => false
];

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

me retornou o seguinte erro:


400
json_invalido
Parâmetro ".headers['x-skip-mtls-checking']", deve ser igual a um dos valores predefinidos
{
"Server": [
"nginx"
],
"Date": [
"Tue, 06 Aug 2024 18:59:18 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"241"
],
"Connection": [
"keep-alive"
],
"x-request-id": [
"xxxx"
],
"Vary": [
"Origin"
],
"Access-Control-Allow-Credentials": [
"true"
],
"ETag": [
"xxx""
]
}

Avatar discord do usuario felipenunes0714

felipenunes0714


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "../../../../../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => ""
];

$body = [
"webhookUrl" => ""
];


try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "/../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => "12345"
];

$body = [
"webhookUrl" => "www.meulink.com"
];

try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

Avatar discord do usuario igor_efi

igor_efi

Ver Respostas

Boa tarde, @marcosvinicius0759! Tudo bem?
Em nossa documentação explicamos como implementar sem a configuração do MLTS: https://dev.efipay.com.br/docs/api-pix/webhooks
Fica na seção Skip-mTLS

Avatar discord do usuario gabreudev

gabreudev

public JSONObject configHook(){

JSONObject options = configuringJsonObject();

options.put("x-skip-mtls-checking", "true");

HashMap params = new HashMap<>();
params.put("chave", "2d9c6bfd-d19e-4123-8a35-c2f0caac55db");

JSONObject body = new JSONObject();
body.put("webhookUrl", "https://bde1-45-170-222-201.ngrok-free.app/webhook/");

try {
EfiPay efi = new EfiPay(options);
JSONObject response = efi.call("pixConfigWebhook", params, body);
System.out.println(response);
return response;

Avatar discord do usuario rubenskuhl

rubenskuhl

Ver Respostas

Mas aí seria TLS e não mTLS. Para ser mTLS, o ngrok precisaria checar se é certificado da Efí... então precisa do x-skip-mtls sim para esse ambiente dev.

Avatar discord do usuario gabreudev

gabreudev

Ver Respostas

JSONObject options = configuringJsonObject();

options.put("x-skip-mtls-checking", "true");

HashMap params = new HashMap<>();
params.put("chave", "minhachave");

JSONObject body = new JSONObject();
body.put("webhookUrl", "https://37c3-45-170-222-201.ngrok-free.app/webhook/");

try {
EfiPay efi = new EfiPay(options);
JSONObject response = efi.call("pixConfigWebhook", params, body);
System.out.println(response);
return response;

}catch (EfiPayException e){
System.out.println(e.getError());
System.out.println(e.getErrorDescription());
return null;
}

Avatar discord do usuario rubenskuhl

rubenskuhl

Ver Respostas

Sim, ngrok usando a opção X-Skip-mTLS-Check é uma opção para testes, sejam no ambiente de homologação ou de produção pra Efí. Só não vale usar em produção externa, pois a falta do mTLS te colocaria em oposição ao regulamento do Pix.