Skip to content

Commit a57c9e7

Browse files
committed
Disable TLS certificate verification when installing nodejs or appium
1 parent 8fe0fcf commit a57c9e7

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Framework/nodejs_appium_installer.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def install_nodejs():
9999
print("Downloading Node.js...")
100100
response = requests.get(url, verify=False)
101101
response.raise_for_status()
102-
with open(archive_path, 'wb') as out_file:
102+
with open(archive_path, "wb") as out_file:
103103
out_file.write(response.content)
104104

105105
try:
@@ -151,7 +151,9 @@ def install_appium():
151151
raise Exception("npm not found. Install Node.js first.")
152152

153153
print("Installing Appium...")
154-
subprocess.run([str(npm_path), "install", "-g", "appium"], check=True)
154+
subprocess.run(
155+
[str(npm_path), "install", "-g", "appium", "--strict-ssl=false"], check=True
156+
)
155157

156158
print("Installing Appium drivers...")
157159
install_drivers(get_required_drivers())
@@ -196,7 +198,9 @@ def check_appium_drivers():
196198
text=True,
197199
)
198200
drivers_data = json.loads(result.stdout)
199-
return [name for name, info in drivers_data.items() if info.get("installed", False)]
201+
return [
202+
name for name, info in drivers_data.items() if info.get("installed", False)
203+
]
200204
except: # noqa: E722
201205
return []
202206

@@ -213,13 +217,20 @@ def check_installations():
213217
if npm_path.exists():
214218
try:
215219
result = subprocess.run(
216-
[str(npm_path), "list", "-g", "--json", "appium"], capture_output=True, text=True
220+
[str(npm_path), "list", "-g", "--json", "appium"],
221+
capture_output=True,
222+
text=True,
217223
)
218224
npm_data = json.loads(result.stdout)
219225
appium_installed = "appium" in npm_data.get("dependencies", {})
220226
except: # noqa: E722
221227
pass
222228

229+
# Disable SSL verification for npm for environments that have proxies
230+
subprocess.run(
231+
[str(npm_path), "config", "set", "strict-ssl", "false"], check=False
232+
)
233+
223234
# Check drivers
224235
required_drivers = get_required_drivers()
225236
installed_drivers = check_appium_drivers() if appium_installed else []
@@ -239,6 +250,9 @@ def setup_nodejs_appium():
239250
try:
240251
update_path() # Ensure Node.js is in PATH from the start
241252

253+
os.environ["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"
254+
os.environ["npm_config_strict_ssl"] = "false"
255+
242256
print("Checking Node.js and Appium installation...")
243257
node_installed, appium_installed, missing_drivers = check_installations()
244258

fix_sytax.patch

Whitespace-only changes.

0 commit comments

Comments
 (0)