PHP mysqli ssl_set() 함수
예 - 객체 지향 스타일
SSL 연결 생성:
<?php
$mysqli = mysqli_init();
if (!$mysqli) {
die("mysqli_init failed");
}
$mysqli -> ssl_set("key.pem", "cert.pem", "cacert.pem", NULL, NULL);
if (!$mysqli -> real_connect("localhost","my_user","my_password","my_db"))
{
die("Connect Error: " . mysqli_connect_error());
}
// Some queries...
$mysqli -> close();
?>
하단의 절차적 스타일의 예를 보십시오.
정의 및 사용
ssl_set() / mysqli_ssl_set() 함수는 SSL을 사용하여 보안 연결을 설정하는 데 사용됩니다. 그러나 이 기능은 OpenSSL 지원이 활성화되어 있지 않으면 아무 작업도 수행하지 않습니다.
참고: 이 함수는 real_connect() 전에 호출되어야 합니다 .
참고: MySQL 네이티브 드라이버는 PHP 5.3.3 이전에 SSL을 지원하지 않습니다. MySQL 네이티브 드라이버는 PHP 5.3 이상부터 Microsoft Windows에서 기본적으로 활성화됩니다.
통사론
객체 지향 스타일:
$mysqli -> ssl_set(key, cert, ca, capath, cipher)
절차 스타일:
mysqli_ssl_set(connection, key, cert, ca, capath, cipher)
매개변수 값
Parameter | Description |
---|---|
connection | Required. Specifies the MySQL connection to use |
key | Required. Specifies the path name to the key file |
cert | Required. Specifies the path name to the certificate file |
ca | Required. Specifies the path name to the certificate authority file |
capath | Required. Specifies the pathname to a directory that contains trusted SSL CA certificates in PEM format |
cipher | Required. Specifies a list of allowable ciphers to use for SSL encryption |
기술적 세부 사항
반환 값: | 항상 참. SSL 설정이 잘못된 경우 연결을 시도할 때 real_connect() 가 오류를 반환합니다. |
---|---|
PHP 버전: | 5+ |
예 - 절차 스타일
SSL 연결 생성:
<?php
$con = mysqli_init();
if (!$con) {
die("mysqli_init failed");
}
mysqli_ssl_set($con, "key.pem", "cert.pem", "cacert.pem", NULL, NULL);
if (!mysqli_real_connect($con, "localhost", "my_user", "my_password", "my_db")) {
die("Connect Error: " . mysqli_connect_error());
}
// Some queries...
mysqli_close($con);
?>
❮ PHP MySQLi 참조