S
S
Sergey2016-04-13 13:02:10
PHP
Sergey, 2016-04-13 13:02:10

How to integrate federal city system (socket, php)?

The challenge is to integrate FSH.
The FSH request is a signed XML message sent via TLS1.0 socket and encrypted according to GOST.
The last gag that can't be beat: SSL operation failed with code 1. OpenSSL Error messages: error:1409017F:SSL routines:ssl3_get_server_certificate:wrong certificate type The
socket is created like this:

$context = stream_context_create(
    array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
//            'local_cert' => 'client_ssl.pem',
//            'cafile' => 'cryptopro.cer',
//            'local_pk' => 'nocerts.pem',
            'allow_self_signed' => true,
//            'ciphers' => 'aGOST:kGOST:aGOST01:GOST94:GOST89MAC:ALL',
//            'disable_compression' => true
        )
    )
);


$socket = stream_socket_client($hostname.':'.$port, $errno, $errstr, 60,
    STREAM_CLIENT_CONNECT, $context);

if (!$socket) {
    die("Не могу соединиться: $errstr ($errno)");
}
if ($socket) {
    fwrite($socket, $xml);
}


If you uncomment 'ciphers' =>..., then there will be no error, but the servers are not friendly either. Those. on my side, the packets go away, but on the FSH side they are not perceived.

Development is on a Windows machine, PHP5.6.15, Apache/2.4.17 (Win32), OpenSSL/1.0.2d The

question is: have you ever connected to FSH? If yes, then implementation advice would be very helpful. And if not, then maybe there are ideas what's wrong?

There is an application written in C++ that works. But it requires CryptoPro and a bunch of other libraries.
Monitored transmitted data using a sniffer. I compared what the reference application sends with what PHP gives out.
Handshake goes the same way, but something is wrong with the transmitted data.
- reference:
00000000 17 03 01 00 08 5B 8D 89 B6 B4 15 2D 1C 17 03 01 .....[Ќ‰ ¶ґ.-....
00000010 3F FF DE BE DC 3B 24 04 3E B2 3D AD AC A3 04 0D ? iYuѕb;$. >І=¬Ј..

- PHP:
00000000 17 03 01 00 04 37 EF 7A 68 17 03 01 18 60 25 F6 .....7pz h....`%c
00000010 73 6E 88 39 2C 7C 94 11 96 3A 9C 18 F9 03 4B 4F sn€9,|”. –:њ.ш.KO

The allocated block contains the size of the transmitted data. In both cases, the size is the same. In the first case, the block is 8 bytes (00 08), in the second 4 (00 04).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2016-04-13
@DmitriyEntelis

Maybe it will help you: https://github.com/curl/curl/issues/447

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question