» »

Davčna blahajna - PHP - certifikati

Davčna blahajna - PHP - certifikati

app5771283 ::

Pozdrav,
vem da je bila tema za davčno blagajno / davčno potrjevanje računo odprta, a sem naletel na težavo bi raje vprašal vas. In sicer zanima me kako je to certifikati. In sicer kaj točno je potrebno narediti. Sem jih pretvarjal is .p12 v .pem , .cer v pem, in jih s curl ukazom poslal. Najprej sem testiral v testnem okolju localhost. Jih tudi preko xampp openssl ukaza pretvarjal. V testnem, domačem okolju stvar funkcionira, lahko pošljem echo ukaz in dobim odgovor. Pri produkcijskem serverju pa ne. Dobim nazaj:

The requested URL was rejected. Please consult with your administrator.
Your support ID is: 8672374891615355559

Ne vem a je problem localhost / server ali moje spločno razumevanje pinninga certifikatov.

Hvala za pomoč

Dodal bi še da se nagibam k JSON API fursa.

app5771283 ::

Trenutno imam takšen flow.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);             ---> https://blagajne-test.fu.gov.si:9002/v1...
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 3000);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 3000);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);          ---> Izklopljen
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false );         ---> Izklopljen, $this->cainfo pa drugače drži njihov certifikat
curl_setopt($curl, CURLOPT_SSLCERT, $this->cert_pem_path);     ---> Pot do .pem testnega certifikata pridobljenega iz pretvorbe .p12 certifikata, ki ga je poslal furs
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $this->cert_pass);    ---> Geslo za certifikat
// curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);        ---> Drži zdručena certifikata TaxCATest.cer in sitest-ca.cer v .pem obliki
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json;charset=utf-8",
));
curl_setopt($curl, CURLOPT_POSTFIELDS, $send_json);         ---> json payload {'echo':'this is echo'}
curl_setopt($curl, CURLINFO_HEADER_OUT, true);

$headers = array();
curl_setopt($curl, CURLOPT_HEADERFUNCTION,
function($curl, $header) use (&$headers)
{
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) // ignore invalid headers
return $len;
$headers[strtolower(trim($header[0]))][] = trim($header[1]);
return $len;
}
);

$response = curl_exec($curl);
$information = curl_getinfo($curl);

if (curl_errno($curl)) {
$error_msg = curl_error($curl);
error_log($error_msg);
}

echo '<pre>';
print_r($headers);
print_r($information);
echo '</pre>';
curl_close($curl);
echo $response;

Nazaj pa dobim is localhosta
Array
(
[host] => Array
(
[0] => blagajne-test.fu.gov.si:9002
)

[accept] => Array
(
[0] => */*
)

[content-type] => Array
(
[0] => application/json;charset=utf-8
)

[content-length] => Array
(
[0] => 27
)

[x-forwarded-for] => Array
(
[0] => 86.58.48.232
)

[access-control-allow-origin] => Array
(
[0] => *
)

[access-control-allow-headers] => Array
(
[0] => origin, x-requested-with, Content-Type, accept
)

[access-control-max-age] => Array
(
[0] => 3628800
)

[access-control-allow-methods] => Array
(
[0] => GET, PUT, POST, DELETE
)

[connection] => Array
(
[0] => keep-alive
)

[set-cookie] => Array
(
[0] => TS016b9802=01a25b10d8419e11767b455e541536dfe15d030a132938ba1f2e6a5502ba864a8d1706e780; Path=/
)

)
Array
(
[url] => https://blagajne-test.fu.gov.si:9002/v1...
[content_type] => application/json;charset=utf-8
[http_code] => 200
[header_size] => 493
[request_size] => 183
[filetime] => -1
[ssl_verify_result] => 19
[redirect_count] => 0
[total_time] => 0.121264
[namelookup_time] => 0.000919
[connect_time] => 0.018381
[pretransfer_time] => 0.090333
[size_upload] => 27
[size_download] => 27
[speed_download] => 223
[speed_upload] => 223
[download_content_length] => 27
[upload_content_length] => 27
[starttransfer_time] => 0.121208
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 84.39.218.166
[certinfo] => Array
(
)

[primary_port] => 9002
[local_ip] => 192.168.0.12
[local_port] => 52627
[http_version] => 2
[protocol] => 2
[ssl_verifyresult] => 0
[scheme] => HTTPS
[appconnect_time_us] => 90283
[connect_time_us] => 18381
[namelookup_time_us] => 919
[pretransfer_time_us] => 90333
[redirect_time_us] => 0
[starttransfer_time_us] => 121208
[total_time_us] => 121264
[request_header] => POST /v1/cash_registers/echo HTTP/1.1
Host: blagajne-test.fu.gov.si:9002
Accept: */*
Content-Type: application/json;charset=utf-8
Content-Length: 27


)

{"echo":"this is a echo"}

Zgodovina sprememb…

app5771283 ::

iz produkcijskega serverja
Array
(
[connection] => Array
(
[0] => close
)

[cache-control] => Array
(
[0] => no-cache
)

[pragma] => Array
(
[0] => no-cache
)

[content-type] => Array
(
[0] => text/html; charset=iso-8859-2
)

[transfer-encoding] => Array
(
[0] => chunked
)

)
Array
(
[url] => https://blagajne-test.fu.gov.si:9002/v1...
[content_type] => text/html; charset=iso-8859-2
[http_code] => 200
[header_size] => 154
[request_size] => 183
[filetime] => -1
[ssl_verify_result] => 19
[redirect_count] => 0
[total_time] => 0.073297
[namelookup_time] => 0.000258
[connect_time] => 0.001497
[pretransfer_time] => 0.071209
[size_upload] => 27
[size_download] => 188
[speed_download] => 2575
[speed_upload] => 369
[download_content_length] => -1
[upload_content_length] => 27
[starttransfer_time] => 0.073184
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 84.39.218.166
[certinfo] => Array
(
)

[primary_port] => 9002
[local_ip] => ***.**.***.**         --> zakrito
[local_port] => 60036
[request_header] => POST /v1/cash_registers/echo HTTP/1.1
Host: blagajne-test.fu.gov.si:9002
Accept: */*
Content-Type: application/json;charset=utf-8
Content-Length: 27


)

The requested URL was rejected. Please consult with your administrator.

Your support ID is: 8672374891696382394

beretnc ::

če pošiljaš na test izven EU, moraš na Furs sporočiti ip, da dodajo na whitelist

app5771283 ::

Najlepša hvala. Sem jim včeraj poslal mail glede te težave in sem malo prej prejel sporočilo glede IP-ja. Drugače pa stran gostijo neoserv.si in sem jih poklical glede njihovih strežnikov, ker mi je znanec delil da so oni imeli težave s tem, ko so imeli njihovo stran na Google Cloud-u. Sicer pa so pri pri neoserv trdili da so vsi njihovi serverji v Sloveniji, zato sem to možnost izločil. Še enkrat najlepša hvala.

app5771283 ::

Pozdrav,
me samo zanima če ima mogoče tudi kdo težave pri preverjanju testnih računov na Fursevem https://blagajne-test.fu.gov.si:9002/ca... naslovu. In sicer meni za vsak račun izpiše da račun ne obstaja, čeprav pa dobim od njih EOR kodo.


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Davčne blagajne (strani: 1 2 3 424 25 26 27 )

Oddelek: Programiranje
1344333579 (73582) Macketina
»

Pornhub s HTTPS protokolom nad požrešne ISP-je (strani: 1 2 )

Oddelek: Novice / Zasebnost
5822294 (10951) M.B.
»

PHP davčna blagajna

Oddelek: Programiranje
188125 (6149) brble
»

cURL

Oddelek: Omrežja in internet
101015 (805) d4vid
»

[PHP] Uporaba cURL s HTTPS

Oddelek: Programiranje
111696 (1439) JercSI

Več podobnih tem