appium / dotnet-client

Extension to the official Selenium dotnet webdriver
Apache License 2.0
381 stars 188 forks source link

How to make the Appium dotnet driver to trust the Appium server certificate? #455

Open alvaro777 opened 3 years ago

alvaro777 commented 3 years ago

Hi there, I am trying to use an SSL enabled Appium server, but when I try to open a session, I get this exception Is there any way to instruct the client to trust the Appium server certificate? Similar to what the "Allow Unauthorized Certificates" option does in Appium Desktop: image

I am using Appium web driver version 4.3.1. Appium server 1.19.0

Thanks, A

Dor-bl commented 2 years ago

I think this question should be placed under appium repo. @mykola-mokhnach / @KazuCocoa do we have such argument that we can pass to appium server?

KazuCocoa commented 2 years ago

It is dotnet client thing. I guess the endpoint has https with self-certificate, or something new certificate which is not valid for existing one. For example, Python 2's bundled certificates had the issue.

Then, a client should relax the validation like ignoring the validation. I haven't dug into the dotnet client's options to relax the validation, but it might have.

Dor-bl commented 2 months ago

@KazuCocoa, Trying to replicate this from my side.

I followed this guide: https://appium.io/docs/en/2.3/guides/tls/ and when I start the appium server with the cert and key I get HTTP: instead of HTTPS:

Here are the logs:

C:\Program Files\OpenSSL-Win64\crt>appium server --port 4724 --ssl-cert-path cert.pem --ssl-key-path key.pem
[Appium] Welcome to Appium v2.5.1
[Appium] Non-default server args:
[Appium] {
[Appium]   port: 4724
[Appium] }
[Appium] The autodetected Appium home path: C:\Users\Dor-B\.appium
[Appium] Attempting to load driver windows...
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver espresso...
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-windows-driver\build\index.js
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-espresso-driver\build\index.js
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-uiautomator2-driver\build\index.js
[Appium] WindowsDriver has been successfully loaded in 2.261s
[Appium] EspressoDriver has been successfully loaded in 2.261s
[Appium] AndroidUiautomator2Driver has been successfully loaded in 2.263s
[HTTP] Enabling TLS/SPDY on the server using the provided certificate
(node:14432) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[Appium] Appium REST http interface listener started on http://0.0.0.0:4724
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium]        http://10.100.102.94:4724/
[Appium]        http://127.0.0.1:4724/ (only accessible from the same host)
[Appium] Available drivers:
[Appium]   - windows@2.1.2 (automationName 'Windows')
[Appium]   - uiautomator2@2.45.1 (automationName 'UiAutomator2')
[Appium]   - espresso@2.38.3 (automationName 'Espresso')
[Appium] Available plugins:
[Appium]   - images@3.0.0
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
mykola-mokhnach commented 2 months ago

@Dor-bl Please always try the most recent server version. The 2.5.1 one is pretty out of date

Dor-bl commented 2 months ago

@mykola-mokhnach Updated to 2.11.3, but still got the same outcome:

[Appium] Welcome to Appium v2.11.3
[Appium] The autodetected Appium home path: C:\Users\Dor-B\.appium
[Appium] Attempting to load driver windows...
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver espresso...
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-windows-driver\build\index.js
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-espresso-driver\build\index.js
[Appium] Requiring driver at C:\Users\Dor-B\.appium\node_modules\appium-uiautomator2-driver\build\index.js
[Appium] WindowsDriver has been successfully loaded in 13.159s
[Appium] EspressoDriver has been successfully loaded in 13.159s
[Appium] AndroidUiautomator2Driver has been successfully loaded in 13.162s
[HTTP] Enabling TLS/SPDY on the server using the provided certificate
(node:23024) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
        http://10.100.102.94:4723/
        http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] Available drivers:
[Appium]   - windows@2.1.2 (automationName 'Windows')
[Appium]   - uiautomator2@2.45.1 (automationName 'UiAutomator2')
[Appium]   - espresso@2.38.3 (automationName 'Espresso')
[Appium] Available plugins:
[Appium]   - images@3.0.0
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
mykola-mokhnach commented 2 months ago

I've checked it locally and it looks like there is a bug in logging. The server itself does start using a secure protocol though. https://github.com/appium/appium/pull/20449 should fix the log line