File: ssl_connection.php

package info (click to toggle)
php-amqplib 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,440 kB
  • sloc: php: 12,624; makefile: 57; sh: 33
file content (31 lines) | stat: -rw-r--r-- 698 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

include(__DIR__ . '/config.php');

use PhpAmqpLib\Connection\AMQPSSLConnection;

define('CERTS_PATH', realpath(__DIR__ . '/../tests/certs'));

$sslOptions = array(
    'cafile' => CERTS_PATH . '/ca_certificate.pem',
    'local_cert' => CERTS_PATH . '/client_certificate.pem',
    'local_pk' => CERTS_PATH . '/client_key.pem',
    'verify_peer' => true,
    'verify_peer_name' => false,
);

$connection = new AMQPSSLConnection(HOST, 5671, USER, PASS, VHOST, $sslOptions);

/**
 * @param \PhpAmqpLib\Connection\AbstractConnection $connection
 */
function shutdown($connection)
{
    $connection->close();
}

register_shutdown_function('shutdown', $connection);

while (true) {
    sleep(1);
}