Updated python notebook for testing connections
"# We will go through a few steps to make sure the connections to Elasticsearch and BloodHound/Neo4J are operational\n",
"\n",
"import urllib3\n",
+ "import ssl\n",
"from elasticsearch import Elasticsearch\n",
- "from redelk_passwords import * # this file contains all relevant credentials\n"
+ "from elasticsearch.connection import create_ssl_context\n",
+ "from redelk_passwords import * # this file contains all relevant credentials"
]
},
{
"# define the connection to our ES instance\n",
"\n",
"urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n",
+ "ssl_context = create_ssl_context()\n",
+ "ssl_context.check_hostname = False\n",
+ "ssl_context.verify_mode = ssl.CERT_NONE\n",
+ "\n",
"es = Elasticsearch(\n",
" ['redelk-elasticsearch'],\n",
" http_auth=(CredESUsername, CredESPassword),\n",
" scheme=\"https\",\n",
" port=9200,\n",
- " verify_certs=False,\n",
+ " ssl_context=ssl_context\n",
")\n"
]
},
"metadata": {},
"outputs": [],
"source": [
- "# Now print the available indices in ES -- this should give output\n",
+ "# Now test the connection to ES -- this should give output\n",
"\n",
- "es.indices.get_alias(index=\"redelk-*\")\n"
+ "if es.ping():\n",
+ " print(\"ES connection successful\")\n",
+ "else:\n",
+ " raise ValueError(\"ES Connection failed\")\n"
]
},
{
