Connector/Net Tutorials
1891
MySQL Server uses the PEM format for certificates and private keys. This tutorial will use the test
certificates from the server test suite by way of example. You can obtain the MySQL Server source
code from
MySQL Downloads
. The certificates can be found in the directory
./mysql-test/
std_data
.
To carry out the steps in this tutorial, you must have Open SSL installed. This can be downloaded for
Microsoft Windows at no charge from
Shining Light Productions
.
Further details on the connection string options used in this tutorial can be found at
Section 20.2.6,
“Connector/Net Connection String Options Reference”
.
Configuring the MySQL Server to use SSL
1. In the MySQL Server configuration file, set the SSL parameters as follows:
ssl-ca=path/to/repo/mysql-test/std_data/cacert.pem
ssl-cert=path/to/repo/mysql-test/std_data/server-cert.pem
ssl-key=path/to/repo/mysql-test/std_data/server-key.pem
Adjust the directories according to the location in which you installed the MySQL source code.
2. In this step you create a test user and set the user to require SSL.
Using the MySQL Command-Line Client, connect as
root
and create the user
sslclient
.
3. To set privileges and requirements, issue the following command:
GRANT ALL PRIVILEGES ON *.* TO sslclient@'%' REQUIRE SSL;
Creating a certificate file to use with the .NET client
1. The .NET client does not use the PEM file format, as .NET does not support this format natively.
You will be using test client certificates from the same server repository, for the purposes of
this example. Convert these to PFX format first. This format is also known as PKCS#12. An
article describing this procedure can be found at the
Citrix website
. From the directory
server-
repository-root/mysql-test/std_data
, issue the following command:
openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -certfile cacert.pem -out client.pfx
2. When asked for an export password, enter the password “pass”. The file
client.pfx
will be
generated. This file is used in the remainder of the tutorial.
Connecting to the server using a file-based certificate
1. You will use PFX file,
client.pfx
you created in the previous step to authenticate the client. The
following example demonstrates how to connect using the
SSL Mode
,
CertificateFile
and
CertificatePassword
connection string options:
using (MySqlConnection connection = new MySqlConnection(
"database=test;user=sslclient;" +
"CertificateFile=H:\\bzr\\mysql-trunk\\mysql-test\\std_data\\client.pfx" +
"CertificatePassword=pass;" +
"SSL Mode=Required "))
{
connection.Open();
}
The path to the certificate file will need to be changed to reflect your individual installation.
Connecting to the server using a store-based certificate
1. The first step is to import the PFX file,
client.pfx
, into the Personal Store. Double-click the file in
Windows explorer. This launches the Certificate Import Wizard.
2. Follow the steps dictated by the wizard, and when prompted for the password for the PFX file, enter
“pass”.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...