Data Encryption Across the Network


If your database connection is not configured to use data encryption, data is sent across the network in a format that is designed for fast transmission. This format does not provide complete protection from hackers, and it can be decoded given some time and effort.

To address data security concerns, you might want to use data encryption to provide a more secure transmission of data. Consider using data encryption in the following scenarios:

NOTE: Data encryption can adversely affect performance because of the additional overhead (mainly CPU usage) required to encrypt and decrypt data.

This section covers the following topics:

Supported Encryption Methods

DataDirect XQuery supports the following encryption methods:

Table 7-4 summarizes the data encryption methods supported by DataDirect XQuery.

Table 7-4. Data Encryption Methods Supported by DataDirect XQuery
Driver
Database-Specific
SSL
DB2 for Linux/UNIX/Windows
X
X1
DB2 for z/OS
X
X2
DB2 for iSeries
 
X3
Informix
 
 
MySQL
 
 
Oracle
 
X
Microsoft SQL Server
 
X4
Sybase
 
X
1Supported for V9.1 Fixpack 2 and higher for Linux/UNIX/Windows.
2Supported for DB2 v9.1 for z/OS.
3Supported for DB2 V5R3 and higher for iSeries.
4Supported for Microsoft SQL Server 2000 and higher.

Database-Specific Data Encryption

The DB2 driver supports a proprietary data encryption protocol for the following DB2 databases:

Configuring Data Encryption for DB2

To configure data encryption for a DB2 database:

  1. Set the AuthenticationMethod property to clearText, encryptedPassword, or encryptedUIDPassword.
  2. Set the EncryptionMethod property to DBEncryption or RequestDBEncryption.

SSL Encryption

SSL works by allowing the client and server to send each other encrypted data that only they can decrypt. SSL negotiates the terms of the encryption in a sequence of events known as the SSL handshake. The handshake involves the following types of authentication:

The version of SSL that is used and which SSL cryptographic algorithm is used depends on which JVM you are using. Refer to your JVM documentation for more information about its SSL support.

Procedures for configuring SSL vary for the databases that support it. See the individual driver chapters for details about configuring SSL:

SSL Server Authentication

When the client makes a connection request, the server presents its public certificate for the client to accept or deny. The client checks the issuer of the certificate against a list of trusted Certificate Authorities (CAs) that resides in an encrypted file on the client known as a truststore. Optionally, the client may check the subject (owner) of the certificate. If the certificate matches a trusted CA in the truststore (and the certificate’s subject matches the value that the application expects), an encrypted connection is established between the client and server. If the certificate does not match, the connection fails and the driver throws an exception.

To check the issuer of the certificate against the contents of the truststore, the driver must be able to locate the truststore and unlock the truststore with the appropriate password. You can specify truststore information in either of the following ways:

Alternatively, you can configure the DataDirect Connect for JDBC drivers to trust any certificate sent by the server, even if the issuer is not a trusted CA. Allowing a driver to trust any certificate sent from the server is useful in test environments because it eliminates the need to specify truststore information on each client in the test environment. If the driver is configured to trust any certificate sent from the server, the issuer information in the certificate is ignored.

SSL Client Authentication (DB2 and Oracle)

If the server is configured for SSL client authentication, the server asks the client to verify its identity after the server has proved its identity. Similar to SSL server authentication, the client sends a public certificate to the server to accept or deny. The client stores its public certificate in an encrypted file known as a keystore.

The driver must be able to locate the keystore and unlock the keystore with the appropriate keystore password. Depending on the type of keystore used, the driver also may need to unlock the keystore entry with a password to gain access to the certificate and its private key.

DataDirect XQuery can use the following types of keystores:

You can specify this information in either of the following ways:

Configuring SSL for DB2

The DB2 driver supports SSL encryption for the following databases:

NOTE: Connection hangs can occur when the driver is configured for SSL and the database server does not support SSL. You may want to set a login timeout using the LoginTimeout property to avoid problems when connecting to a server that does not support SSL.

To configure SSL encryption:

  1. Set the EncryptionMethod property to SSL.
  2. Specify the location and password of the truststore file used for SSL server authentication. Either set the TrustStore and TrustStore properties or their corresponding Java system properties (javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword, respectively).
  3. To validate certificates sent by the database server, set the ValidateServerCertificate property to true.
  4. Optionally, set the HostNameInCertificate property to a host name to be used to validate the certificate. The HostNameInCertificate property provides additional security against man-in-the-middle (MITM) attacks by ensuring that the server the driver is connecting to is the server that was requested.
  5. If your database server is configured for SSL client authentication, configure your keystore information:
    1. Specify the location and password of the keystore file. Either set the KeyStore and KeyStore properties or their corresponding Java system properties (javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword, respectively).
    2. If any key entry in the keystore file is password-protected, set the KeyPassword property to the key password.

Configuring SSL for Oracle

The Oracle driver supports SSL encryption for the following databases:

Oracle Advanced Security must be enabled on the database server to support SSL.

NOTE: Connection hangs can occur when the driver is configured for SSL and the database server does not support SSL. You may want to set a login timeout using the LoginTimeout property to avoid problems when connecting to a server that does not support SSL.

To configure SSL encryption:

  1. Set the EncryptionMethod property to SSL.
  2. Specify the location and password of the truststore file used for SSL server authentication. Either set the TrustStore and TrustStore properties or their corresponding Java system properties (javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword, respectively).
  3. To validate certificates sent by the database server, set the ValidateServerCertificate property to true.
  4. Optionally, set the HostNameInCertificate property to a host name to be used to validate the certificate. The HostNameInCertificate property provides additional security against man-in-the-middle (MITM) attacks by ensuring that the server the driver is connecting to is the server that was requested.
  5. If your database server is configured for SSL client authentication, configure your keystore information:
    1. Specify the location and password of the keystore file. Either set the KeyStore and KeyStore properties or their corresponding Java system properties (javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword, respectively).
    2. If any key entry in the keystore file is password-protected, set the KeyPassword property to the key password.

Configuring SSL for Microsoft SQL Server

The SQL Server driver supports SSL encryption for the following databases:

Depending on your Microsoft SQL Server configuration, you can choose to encrypt all data, including the login request, or encrypt the login request only. Encrypting login requests, but not data, is useful for the following scenarios:

NOTE: When SSL is enabled, the driver communicates with database protocol packets set by the server’s default packet size. Any value set by the PacketSize property is ignored.

Using SSL with Microsoft SQL Server

If your Microsoft SQL Server database server has been configured with an SSL certificate signed by a trusted CA, the server can be configured so that SSL encryption is either optional or required. When required, connections from clients that do support SSL encryption fail.

Although a signed trusted SSL certificate is recommended for the best degree of security, Microsoft SQL Server 2005 and higher can provide limited security protection even if an SSL certificate has not been configured on the server. If a trusted certificate is not installed, the server will use a self-signed certificate to encrypt the login request, but not the data.

Table 7-5 shows how the different EncryptionMethod property values behave with different Microsoft SQL Server configurations.

Table 7-5. EncryptionMethod Property and Microsoft SQL Server Configurations
Value
No SSL Certificate
SSL Optional
SSL Required
noEncryption
Login request and data are not encrypted.
Login request and data are not encrypted.
Connection attempt fails.
SSL
Connection attempt fails.
Login request and data are encrypted.
Login request and data are encrypted.
requestSSL
Login request and data are not encrypted.
Login request and data are encrypted.
Login request and data are encrypted.
loginSSL
Microsoft SQL Server 2005 and higher: Login request is encrypted; data is not.
Microsoft SQL Server 2000: Connection attempt fails.
Login request is encrypted; data is not.
Login request and data are encrypted.

How to Configure SSL for Microsoft SQL Server

To configure SSL encryption for Microsoft SQL Server:

  1. Choose the type of encryption for your application:
    • If you want the driver to encrypt all data, including the login request, set the EncryptionMethod property to SSL or requestSSL.
    • If you want the driver to encrypt only the login request, set the EncryptionMethod property to loginSSL.
  2. Specify the location and password of the truststore file used for SSL server authentication. Either set the TrustStore and TrustStore properties or their corresponding Java system properties (javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword, respectively).
  3. To validate certificates sent by the database server, set the ValidateServerCertificate property to true.
  4. Optionally, set the HostNameInCertificate property to a host name to be used to validate the certificate. The HostNameInCertificate property provides additional security against man-in-the-middle (MITM) attacks by ensuring that the server the driver is connecting to is the server that was requested.

Configuring SSL for Sybase

The Sybase driver supports SSL encryption for the following databases:

In addition, the Sybase Security and Directory Services package, ASE_SECDIR, is required.

NOTE: Connection hangs can occur when the driver is configured for SSL and the database server does not support SSL. You may want to set a login timeout using the LoginTimeout property to avoid problems when connecting to a server that does not support SSL.

To configure SSL encryption:

  1. Set the EncryptionMethod property to SSL.
  2. Specify the location and password of the truststore file used for SSL server authentication. Either set the TrustStore and TrustStore properties or their corresponding Java system properties (javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword, respectively).
  3. To validate certificates sent by the database server, set the ValidateServerCertificate property to true.
  4. Optionally, set the HostNameInCertificate property to a host name to be used to validate the certificate. The HostNameInCertificate property provides additional security against man-in-the-middle (MITM) attacks by ensuring that the server the driver is connecting to is the server that was requested.