Chaffelson / nipyapi

A convenient Python wrapper for Apache NiFi
Other
244 stars 76 forks source link

Secure Connection Issue #213

Closed tahakashaf closed 10 months ago

tahakashaf commented 4 years ago

Description

I have a nifi standalone 1.11.3 running securely. I generated self signed certificate using nifi-toolkit and provided the jks path and password as in below code but secure connection is failing.

What I Did

from nipyapi.nifi import configuration as nifi_config
import nipyapi

secured_nifi_url = 'https://localhost:9443/nifi-api'
tls_env_vars = {
    'AUTH': 'tls',
    'KEYSTORE_PATH': 'nifi_secure/conf/keystore.jks',
    'KEYSTORE_TYPE': 'JKS',
    'KEYSTORE_PASSWORD': 'password',
    'TRUSTSTORE_PATH': '/nifi_secure/conf/truststore.jks',
    'TRUSTSTORE_PASSWORD': 'password',
    'TRUSTSTORE_TYPE': 'JKS',
    'INITIAL_ADMIN_IDENTITY': 'CN=taha, OU=NIFI'
}

nifi_config.host = unsecured_nifi_url
print(nipyapi.canvas.get_root_pg_id())

self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123) UPDATE :- I believe, i need to update config.py

default_certs_path = os.path.join(PROJECT_ROOT_DIR, 'demo/keys') default_ssl_context = { 'ca_file': os.path.join(default_certs_path, 'localhost-ts.pem'), 'client_cert_file': os.path.join(default_certs_path, 'client-cert.pem'), 'client_key_file': os.path.join(default_certs_path, 'client-key.pem'), 'client_key_password': 'clientPassword' }

@Chaffelson Can you pls help me map I have below files that I have generated below from toolkit

../nifi-toolkit-1.11.3/target/ ├── CN=taha_OU=NIFI.p12 ├── CN=taha_OU=NIFI.password ├── localhost │   ├── keystore.jks │   ├── nifi.properties │   └── truststore.jks ├── nifi-cert.pem └── nifi-key.key

Urgency

A blocker for dynamically creating flows in nifi environment.

janis-ax commented 2 years ago

@tahakashaf idk if this is relevant to you, but following should help you:

nipyapi.config.nifi_config.verify_ssl = False
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Chaffelson commented 10 months ago

Closing as old, please reopen if the issue persists