Skip to main content

Python クライアントでの TLS

InterSystems IRIS との通信に TLS を使用するための Python クライアントの構成

Python クライアント・アプリケーションで InterSystems IRIS® データ・プラットフォームと通信するときに TLS が使用されるようにこのアプリケーションを構成できます。TLS を使用する Python 接続を確立するには、以下の手順を実行します。

  1. "TLS を使用するための InterSystems IRIS スーパーサーバの構成" の説明に従って TLS を使用するようにスーパーサーバを構成します。

  2. サーバ証明書を検証するための関連する CA 証明書がインストールされていることを確認します。

  3. お使いのバージョンに基づいて Python クライアントを構成します。バージョン 4 では、SSL 構成に SSLDefs.ini ファイルを使用します。このファイルを構成する方法の詳細は、"設定ファイルを使用した Windows クライアントからの接続" を参照してください。

    import ssl
    import iris
    
    context = ssl.SSLContext(ssl.PROTOCOL_TLS)
    context.verify_mode = ssl.CERT_REQUIRED
    cafile = "path/to/CACert.pem"
    context.load_verify_locations(cafile)
    context.load_cert_chain("path/to/Cert.pem", "path/to/Key.pem", "apasswordifany")
    
    connection =  iris.createConnection("127.0.0.1", 1972, "user", "_SYSTEM", "SYS", 10000, sslcontext=context)
    ...
    connection.close()
    
    import iris
    # On Windows lookup is based on address-port pair in SSLDefs.ini. -- GDConfig will be used
    connection =  iris.createConnection("127.0.0.1", 1972, "user", "_SYSTEM", "SYS", 10000, sslconfig=True)
    
    # On Unix lookup is based on a provided configuration name instead of address-port pair. -- GDConfig2 will be used
    # connection =  iris.createConnection("127.0.0.1", 1972, "user", "_SYSTEM", "SYS", 10000, sslconfig="GDConfig2")
    ...
    connection.close()
    

以下に、上記の V4 コードで使用される Python クライアント構成の SSLDefs.ini ファイルの例を示します。

[IRIS]
Address=127.0.0.1
Port=1972
SSLConfig=GDConfig
 
[GDConfig]
TLSMinVersion=16
TLSMaxVersion=32
KeyType=2
VerifyPeer=0
CipherList=ALL:!aNULL:!eNULL:!EXP:!SSLv2
Ciphersuites=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
Password=apasswordifany
CertFile=path/to/Cert.pem
KeyFile=path/to/Key.pem
CAfile=path/to/CACert.pem
 
[GDConfig2]
TLSMinVersion=16
TLSMaxVersion=32
KeyType=2
VerifyPeer=0
CipherList=ALL:!aNULL:!eNULL:!EXP:!SSLv2
Ciphersuites=TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
Password=apasswordifany
CertFile=path/to/AnotherCert.pem
KeyFile=path/to/AnotherKey.pem
CAfile=path/to/AnotherCACert.pem
Note:

このドキュメントの作成時点では、Python TLSv1.3 の暗号を変更することはできません。TLSv1.3 の場合は暗号スイートのみが使用され、値はこのリストと同じでなければなりません (順序は異なることがあります)。

TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

TLSv1.3 より前のバージョンの場合は暗号リストのみが使用されます。

FeedbackOpens in a new tab