Skip to content

Commit fe435a7

Browse files
Improve error message when NNE is required by the server.
1 parent 94c1573 commit fe435a7

File tree

4 files changed

+71
-44
lines changed

4 files changed

+71
-44
lines changed

doc/src/release_notes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Thin Mode Changes
4747
#) Error ``DPY-3001: bequeath is only supported in python-oracledb thick
4848
mode`` is now raised when attempting to connect to the database without a
4949
connect string.
50+
#) Error ``DPY-3001: Native Network Encryption and Data Integrity is only
51+
supported in python-oracledb thick mode`` is now the secondary error
52+
message returned when Oracle Net NNE or checksumming is required by the
53+
database. Previously, the error ``DPY-4011: the database or network closed
54+
the connection`` was raised.
5055
#) Optimization: the connect descriptor sent to the database does not include
5156
the RETRY_DELAY parameter unless the RETRY_COUNT parameter is also
5257
specified.

doc/src/user_guide/troubleshooting.rst

Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,54 @@ DPY Error Messages
253253
The python-oracledb Thin mode code and python-oracledb Thick mode code
254254
generates error messages with the prefix ``DPY``.
255255

256+
.. _dpy3001:
257+
258+
DPY-3001
259+
++++++++
260+
261+
**Message:** ``DPY-3001: Native Network Encryption and Data Integrity is only
262+
supported in python-oracledb thick mode``
263+
264+
**Action:** To verify if NNE or checksumming are enabled, you can use the
265+
following query::
266+
267+
SELECT network_service_banner FROM v$session_connect_info;
268+
269+
If NNE is enabled, then this query prints output that includes the
270+
available encryption service, the crypto-checksumming service, and the
271+
algorithms in use, such as::
272+
273+
NETWORK_SERVICE_BANNER
274+
-------------------------------------------------------------------------------------
275+
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
276+
Encryption service for Linux: Version 19.0.1.0.0 - Production
277+
AES256 Encryption service adapter for Linux: Version 19.0.1.0.0 - Production
278+
Crypto-checksumming service for Linux: Version 19.0.1.0.0 - Production
279+
SHA256 Crypto-checksumming service adapter for Linux: Version 19.0.1.0.0 - Production
280+
281+
If NNE is not enabled, then the query will only print the available encryption
282+
and crypto-checksumming services in the output. For example::
283+
284+
NETWORK_SERVICE_BANNER
285+
-------------------------------------------------------------------------------------
286+
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
287+
Encryption service for Linux: Version 19.0.1.0.0 - Production
288+
289+
If NNE or checksumming are enabled, you can resolve this error by either:
290+
291+
- Changing the architecture to use Transport Layer Security (TLS), which is
292+
supported in python-oracledb Thin and Thick modes. See `Configuring
293+
Transport Layer Security Encryption
294+
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8B82DD7E-7189-4FE9-8F3B-4E521706E1E4>`__.
295+
- Or :ref:`enabling python-oracledb Thick mode <enablingthick>`.
296+
297+
.. seealso::
298+
299+
`Oracle Database Security Guide <https://www.oracle.com/pls/topic/lookup?
300+
ctx=dblatest&id=DBSEG>`__ for more information about Oracle Data Network
301+
Encryption and Integrity, and for information about configuring TLS
302+
network encryption.
303+
256304
DPY-3010
257305
++++++++
258306

@@ -330,48 +378,15 @@ DPY-4011
330378
**Cause:** If this occurs when using an already opened connection, additional
331379
messages may indicate a reason.
332380

333-
If the error occurs when creating a connection or connection pool, the common
334-
cause is that Oracle Database has Native Network Encryption (NNE) enabled. NNE
335-
is only supported in python-oracledb Thick mode.
336-
337-
**Action:** To verify if NNE is enabled, you can use the following query::
338-
339-
SELECT network_service_banner FROM v$session_connect_info;
340-
341-
If NNE is enabled, then this query prints output that includes the
342-
available encryption service, the crypto-checksumming service, and the
343-
algorithms in use, such as::
344-
345-
NETWORK_SERVICE_BANNER
346-
-------------------------------------------------------------------------------------
347-
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
348-
Encryption service for Linux: Version 19.0.1.0.0 - Production
349-
AES256 Encryption service adapter for Linux: Version 19.0.1.0.0 - Production
350-
Crypto-checksumming service for Linux: Version 19.0.1.0.0 - Production
351-
SHA256 Crypto-checksumming service adapter for Linux: Version 19.0.1.0.0 - Production
352-
353-
If NNE is not enabled, then the query will only print the available encryption
354-
and crypto-checksumming services in the output. For example::
355-
356-
NETWORK_SERVICE_BANNER
357-
-------------------------------------------------------------------------------------
358-
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
359-
Encryption service for Linux: Version 19.0.1.0.0 - Production
381+
If the error occurs when creating a connection or connection pool with
382+
python-oracledb 2 or earlier, the common cause is that Oracle Database has
383+
Native Network Encryption (NNE) enabled. NNE and Oracle Net checksumming are
384+
only supported in python-oracledb Thick mode.
360385

361-
If NNE is enabled, you can resolve this error by either:
386+
**Action:** Review if NNE or checksumming are enabled. See
387+
:ref:`DPY-3001 <dpy3001>` for solutions.
362388

363-
- Changing the architecture to use Transport Layer Security (TLS), which is
364-
supported in python-oracledb Thin and Thick modes. See `Configuring
365-
Transport Layer Security Encryption
366-
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8B82DD7E-7189-4FE9-8F3B-4E521706E1E4>`__.
367-
- Or :ref:`enabling python-oracledb Thick mode <enablingthick>`.
368-
369-
.. seealso::
370-
371-
`Oracle Database Security Guide <https://www.oracle.com/pls/topic/lookup?
372-
ctx=dblatest&id=DBSEG>`__ for more information about Oracle Data Network
373-
Encryption and Integrity, and for information about configuring TLS
374-
network encryption.
389+
If additional messages indicate a reason, follow their guidance.
375390

376391
.. _oraerr:
377392

src/oracledb/impl/thin/constants.pxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ cdef enum:
268268
cdef enum:
269269
TNS_GSO_DONT_CARE = 0x0001
270270
TNS_GSO_CAN_RECV_ATTENTION = 0x0400
271+
TNS_NSI_NA_REQUIRED = 0x10
271272
TNS_NSI_DISABLE_NA = 0x04
272273
TNS_NSI_SUPPORT_SECURITY_RENEG = 0x80
273274

src/oracledb/impl/thin/messages.pyx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,8 @@ cdef class ConnectMessage(Message):
18561856
cdef:
18571857
uint16_t protocol_version, protocol_options
18581858
const char_type *redirect_data
1859-
uint32_t flags = 0
1859+
uint32_t flags2 = 0
1860+
uint8_t flags1
18601861
bytes db_uuid
18611862
if buf._current_packet.packet_type == TNS_PACKET_TYPE_REDIRECT:
18621863
if not self.read_redirect_data_len:
@@ -1875,13 +1876,18 @@ cdef class ConnectMessage(Message):
18751876
if protocol_version < TNS_VERSION_MIN_ACCEPTED:
18761877
errors._raise_err(errors.ERR_SERVER_VERSION_NOT_SUPPORTED)
18771878
buf.read_uint16be(&protocol_options)
1878-
buf.skip_raw_bytes(20)
1879+
buf.skip_raw_bytes(10)
1880+
buf.read_ub1(&flags1)
1881+
if flags1 & TNS_NSI_NA_REQUIRED:
1882+
feature = "Native Network Encryption and Data Integrity"
1883+
errors._raise_not_supported(feature)
1884+
buf.skip_raw_bytes(9)
18791885
buf.read_uint32be(&buf._caps.sdu)
18801886
if protocol_version >= TNS_VERSION_MIN_OOB_CHECK:
18811887
buf.skip_raw_bytes(5)
1882-
buf.read_uint32be(&flags)
1888+
buf.read_uint32be(&flags2)
18831889
buf._caps._adjust_for_protocol(protocol_version, protocol_options,
1884-
flags)
1890+
flags2)
18851891
buf._transport._full_packet_size = True
18861892
elif buf._current_packet.packet_type == TNS_PACKET_TYPE_REFUSE:
18871893
response = self.error_info.message

0 commit comments

Comments
 (0)