php - Connecting to SQL Server 2012 on IIS8 with PHP_SQLSRV -
this project, doesn't require extreme levels of caution/security - i'd working , improve there.
how can php connect sql server 2012
what have done successfully:
- enabled mixed authentication on sql server 2012
- established account using sql authentication
- set fastcgi on iis , configured php.ini
- .php scripts in web root execute successfully
- i can use ssms connect locally sql database using credentials (sql authentication) created
the problem:
- i cannot use php script connect local sql database.
what have considered, not understand enough diagnose:
- that http connections iis impersonating iusr, has permissions read/execute php scripts in web root, may not have permission connect server?
- that reason connection dialogue ineffective
here connect script:
$servername = 'localhost'; $connectioninfo = array( 'database'=>'database', 'encrypt'=>'1', 'uid'=>'user', 'pwd'=>'password' ); $connection = sqlsrv_connect($servername, $connectioninfo); if( $connection == false ) { echo "no connection established.\n"; die( print_r( sqlsrv_errors(), true)); }
here errors (unfortunately php not pretty print them):
no connection established. array ( [0] => array ( [sqlstate] => 08001 [code] => -2146893019 [message] => [microsoft][sql server native client 11.0]ssl provider: certificate chain issued authority not trusted. ) [1] => array ( [sqlstate] => 08001 [code] => -2146893019 [message] => [microsoft][sql server native client 11.0]client unable establish connection ) )
i tried using process monitor check w3wp.exe when load script through browser - don't know how paste information that, there doesn't seem wrong output.
the error message straight-forward: ssl certificate you're using on sql server self-signed , not trusted consumer.
possible solutions include:
- disable ssl/tls on sql server
- use non-secured connection sql server
- add self-signed certificate consumer's trusted certificate store
- get trusted certificate public ca (namecheap them less $20)
Comments
Post a Comment