Protocol Version | Supported or Not |
TLS 1.2 | Supported (Recommended) |
TLS 1.3 | Supported (Recommended) |
TLS 1.0 / TLS 1.1 | No longer recommended. Whether it is available depends on the OpenSSL security policy of the runtime environment. |

TencentDB-TDSQL-B-SSL-CA.zip) and contains the following three files:ca.p7b file: This file is used to import the CA certificate in Windows systems.ca.jks file: This file serves as the truststore and keystore storage file for Java. The password is uniformly set to tencentdb. It is used to import the CA certificate chain in Java programs.ca.pem file: This file is used to import the CA certificate in other systems or applications.connection is being used error occurs, it is usually because an existing session has not been disconnected. Close Navicat and try again.--ssl-mode=REQUIRED) cannot connect. Confirm that this operation has no impact on your business before you proceed.mysql -h <IP address> --ssl-ca=<ca certificate> --ssl-mode=REQUIRED -P <port number> -u <username> -p
VERIFY_CA or VERIFY_IDENTITY, use the following command to connect to the instance.mysql -h <IP address> --ssl-ca=<ca certificate> --ssl-mode=VERIFY_CA -P <port number> -u <username> -p
--ssl-mode parameter specifies the SSL mode. Typically, the REQUIRED and VERIFY_CA modes are recommended. These modes require the MySQL client to connect to the MySQL server using the SSL/TLS protocol and to verify the server's SSL/TLS certificate. The VERIFY_IDENTITY mode, in addition to requiring verification of the server's SSL/TLS certificate, also requires the hostname used by the client to match the identifier in the server certificate. Otherwise, the MySQL client will refuse to connect to the MySQL server.$conn = mysqli_init();mysqli_ssl_set($conn, NULL, NULL, "<path to the downloaded certificate>", NULL, NULL);mysqli_real_connect($conn, '<database access address>', '<database access username>', '<database access password>', '<specified database to access>', <access port>, MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);if (mysqli_connect_errno($conn)) {die('Failed to connect to MySQL: '.mysqli_connect_error());}
$options = array(PDO::MYSQL_ATTR_SSL_CA => '<path to the downloaded certificate>');$db = new PDO('mysql:host=<database access address>;port=<access port>;dbname=<specified database to access>', '<database access username>', '<database access password>', $options);
# generate truststore and keystore in codeString importCert = " -import "+" -alias mysqlServerCACert "+" -file " + ssl_ca +" -keystore truststore "+" -trustcacerts " +" -storepass password -noprompt ";String genKey = " -genkey -keyalg rsa " +" -alias mysqlClientCertificate -keystore keystore " +" -storepass password123 -keypass password " +" -dname CN=MS ";sun.security.tools.keytool.Main.main(importCert.trim().split("\\\\s+"));sun.security.tools.keytool.Main.main(genKey.trim().split("\\\\s+"));# use the generated keystore and truststoreSystem.setProperty("javax.net.ssl.keyStore", "<path to the downloaded certificate>");System.setProperty("javax.net.ssl.keyStorePassword","tencentdb");System.setProperty("javax.net.ssl.trustStore", "<path to the downloaded certificate>");System.setProperty("javax.net.ssl.trustStorePassword","tencentdb");url = String.format("jdbc:mysql://%s/%s?serverTimezone=UTC&useSSL=true", '<database access address>', '<specified database to access>');properties.setProperty("user", '<database access username>');properties.setProperty("password", '<database access password>');conn = DriverManager.getConnection(url, properties);
var builder = new MySqlConnectionStringBuilder{Server = "<database access address>",UserID = "<database access username>",Password = "<database access password>",Database = "<specified database to access>",SslMode = MySqlSslMode.VerifyCA,SslCa = "<downloaded certificate>",};using (var connection = new MySqlConnection(builder.ConnectionString)){connection.Open();}
try:conn = mysql.connector.connect(user='<database access username>',password='<database access password>',database='<specified database to access>',host='<database access address>',ssl_ca='<path to the downloaded certificate>')except mysql.connector.Error as err:print(err)
conn = pymysql.connect(user='<database access username>',password='<database access password>',database='<specified database to access>',host='<database access address>',ssl={'ca': '<path to the downloaded certificate>'})
DATABASES = {'default': {'ENGINE': 'django.db.backends.mysql','NAME': '<specified database to access>','USER': '<database access username>','PASSWORD': '<database access password>','HOST': '<database access address>','PORT': '<access port>','OPTIONS': {'ssl': {'ca': '<path to the downloaded certificate>'}}}}
var fs = require('fs');var mysql = require('mysql');const serverCa = [fs.readFileSync("<path to the downloaded certificate>", "utf8")];var conn=mysql.createConnection({host:"<database access address>",user:"<database access username>",password:"<database access password>",database:"<specified database to access>",port:<access port>,ssl: {rejectUnauthorized: true,ca: serverCa}});conn.connect(function(err) {if (err) throw err;});
rootCertPool := x509.NewCertPool()pem, _ := ioutil.ReadFile("<path to the downloaded certificate>")if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {log.Fatal("Failed to append PEM.")}mysql.RegisterTLSConfig("custom", &tls.Config{RootCAs: rootCertPool})var connectionString stringconnectionString = fmt.Sprintf("%s:%s@tcp(%s:<access port>)/%s?allowNativePasswords=true&tls=custom","<database access username>" , "<database access password>", "<database access address>", '<specified database to access>')db, _ := sql.Open("mysql", connectionString)
client = Mysql2::Client.new(:host => '<database access address>',:username => '<database access username>',:password => '<database access password>',:database => '<specified database to access>',:sslca => '<path to the downloaded certificate>')
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários