hussein-awala commented on code in PR #30418:
URL: https://github.com/apache/airflow/pull/30418#discussion_r1155381051


##########
airflow/providers/neo4j/hooks/neo4j.py:
##########
@@ -61,12 +61,29 @@ def get_conn(self) -> Driver:
 
         is_encrypted = self.connection.extra_dejson.get("encrypted", False)
 
-        self.client = GraphDatabase.driver(
-            uri, auth=(self.connection.login, self.connection.password), 
encrypted=is_encrypted
-        )
+        self.client = self.get_client(self.connection, is_encrypted, uri)
 
         return self.client
 
+    def get_client(self, conn: Connection, encrypted: bool, uri: str) -> 
Driver:
+        """
+        Function to determine that relevant driver based on extras.
+        :param conn: Connection object.
+        :param encrypted: boolean if encrypted connection or not.
+        :return: Neo4jDriver
+        """
+        # Self signed certificates
+        ssc = conn.extra_dejson.get("certs_self_signed", False)
+
+        # Only certificates signed by CA.
+        trusted_ca = conn.extra_dejson.get("certs_trusted_ca", False)
+
+        if trusted_ca or ssc:
+            driver = GraphDatabase.driver(uri, auth=(conn.login, 
conn.password))
+        else:
+            driver = GraphDatabase.driver(uri, auth=(conn.login, 
conn.password), encrypted=encrypted)

Review Comment:
   I see. Since the error is related to the used scheme, why we don't add the 
config according to the provided scheme:
   ```python
       def get_client(self, conn: Connection, encrypted: bool, uri: str) -> 
Driver:
           parsed_uri = urlsplit(uri)
           kwargs = {}
           if parsed_uri.scheme in ["bolt", "neo4j"]:
               kwargs["encrypted"] = encrypted
           return GraphDatabase.driver(uri, auth=(conn.login, conn.password), 
**kwargs)
   ```
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to