Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run testCafe with HTTPS #2924

Closed
doronsever opened this issue Oct 2, 2018 · 20 comments
Closed

Cannot run testCafe with HTTPS #2924

doronsever opened this issue Oct 2, 2018 · 20 comments
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@doronsever
Copy link

Are you requesting a feature or reporting a bug?

BUG

What is the current behavior?

When trying to tun testcafe using HTTPS, the browser always says:
localhost uses an unsupported protocol.
ERR_SSL_VERSION_OR_CIPHER_MISMATCH

What is the expected behavior?

Running testcafe on HTTPS

How would you reproduce the current behavior (if this is a bug)?

I'm trying to set up my local env to use HTTPS.
The reason is that I'm using Angular and it produces source maps and also images are not loaded.
If I'm using testcafe via plain HTTP, I get an error when the tests finish saying: Error [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"

I went over this tutorial: http://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/connect-to-the-testcafe-server-over-https.html and trying to use it via the cli but without success.

I tried creating a local PFX file, or using public key + cert. Non will work.

For example, I went over this tutorial: https://medium.com/@jonsamp/how-to-set-up-https-on-localhost-for-macos-b597bcf935ee

And then run this testcafe command:
testcafe chrome e2e/tests/analyze/ --ssl key=~/.localhost-ssl/localhost.key cert=~/.localhost-ssl/localhost.crt --allow-insecure-localhost --allow-running-insecure-content --dev --hostname=localhost

But still the same result.

Is it a bug or am I doing something wrong?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

Specify your

  • operating system: macOS
  • testcafe version: 0.22
  • node.js version: 9.7.1
@miherlosev miherlosev added the TYPE: question The issue contains a question that won't be addressed. label Oct 3, 2018
@miherlosev
Copy link
Collaborator

I see the parameters are incorrectly used in your example.
Try this command line:

testcafe "chrome --allow-insecure-localhost --allow-running-insecure-content" e2e/tests/analyze/ --ssl key=~/.localhost-ssl/localhost.key;cert=~/.localhost-ssl/localhost.crt  --dev --hostname=localhost

@doronsever
Copy link
Author

@miherlosev this doesn't help also...
I also tried using the crt+key from browser-sync just like I'm using when running my Angular localhost on https but without success...

testcafe 'chrome --allow-insecure-localhost' e2e/tests/analyze/ --hostname=localhost --ssl key=/node_modules/browser-sync/lib/server/certs/server.key;cert=/node_modules/browser-sync/lib/server/certs/server.crt

@miherlosev
Copy link
Collaborator

Could you please provide a simple example that I can run on my computer?

@doronsever
Copy link
Author

Sure, which example do you need?
I paste you how I run the command in the previous reponse

@miherlosev
Copy link
Collaborator

Application sources, test code and certificates.

@doronsever
Copy link
Author

I can't give you access to the source code as this is our production code...
The certificates that I'm using can be generated using this tutorial: https://medium.com/@jonsamp/how-to-set-up-https-on-localhost-for-macos-b597bcf935ee

You can just install a fresh Angular project from the angular cli
Add a test file and try to run the command I wrote above...
The test itself is not important since the browser doesn't try to connect to the angular application since there is an SSL error...

@miherlosev miherlosev added STATE: Need clarification An issue lacks information for further research. and removed TYPE: question The issue contains a question that won't be addressed. labels Oct 3, 2018
@doronsever
Copy link
Author

@miherlosev I've created an empty Angular project by your request.
https://github.com/doronsever/my-tcf-ssl
Just clone it, run npm install
And then run your command testcafe "chrome --allow-insecure-localhost --allow-running-insecure-content" e2e/tests/analyze/ --ssl key=./certs/localhost.key;cert=./certs/localhost.crt --dev --hostname=localhost

@miherlosev
Copy link
Collaborator

Ok. I am investigating the problem

@miherlosev
Copy link
Collaborator

Yes, it's a bug. We will fix it in the current development sprint.

@miherlosev miherlosev added TYPE: bug The described behavior is considered as wrong (bug). AREA: server and removed STATE: Need clarification An issue lacks information for further research. labels Oct 3, 2018
@miherlosev miherlosev added this to the Sprint #19 milestone Oct 3, 2018
@doronsever
Copy link
Author

Great, it will also be great if you can improve the documentation on how to use it.
I would never have guessed that the right way to use the SSL params will be --ssl key=./certs/localhost.key;cert=./certs/localhost.crt

miherlosev pushed a commit to miherlosev/testcafe that referenced this issue Oct 4, 2018
@miherlosev
Copy link
Collaborator

The fix is already in PR.

I would never have guessed that the right way to use the SSL params will be --ssl key=./certs/localhost.key;cert=./certs/localhost.crt

We have an example of using the --ssl option and a help topic that describes the main concepts.

@doronsever
Copy link
Author

We have an example of using the --ssl option and a help topic that describes the main concepts.

I think it will be more clear how to implement it with a dedicated example. Friendly advice :)

@doronsever
Copy link
Author

@miherlosev I still cannot use local variables after upgrading to 0.23.0

I'm running: testcafe 'chrome --allow-insecure-localhost' e2e/tests/analyze/ --hostname=localhost --ssl key=/node_modules/browser-sync/lib/server/certs/server.key;cert=/node_modules/browser-sync/lib/server/certs/server.crt

And getting:

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

@doronsever
Copy link
Author

@miherlosev ok I've managed to workaround the error code I wrote, but now it seems that it doesn't work.
The browser gets open and it is telling me:

This site can’t provide a secure connection localhost uses an unsupported protocol.
ERR_SSL_VERSION_OR_CIPHER_MISMATCH

@LavrovArtem
Copy link
Contributor

Related to DevExpress/testcafe-hammerhead#1806

@kaitmore
Copy link

@doronsever
I was experiencing this same issue using a pfx cert. I realized that testcafe was only picking up the first option passed to the --ssl flag, (in your case, 'key'). If I wrapped the whole thing in quotes like, --ssl 'key=path/to/key;cert=path/to/cert;' it works!

@doronsever
Copy link
Author

Wow...
OK, I will check it out. Thanks!
@miherlosev another reason why you should add this to your docs :)

@miteshsavani
Copy link

@kaitmore It is not working for me even if i put the quotes like --ssl 'key=path/to/key;cert=path/to/cert;' i am facing same issue
This site can’t provide a secure connection localhost uses an unsupported protocol. ERR_SSL_VERSION_OR_CIPHER_MISMATCH

@sijosyn
Copy link

sijosyn commented Jan 15, 2019

Following worked for me. TestCafe ver 0.23.3 & Chrome 71.0 (on Mac 10.14.2)

testcafe 'chrome --allow-insecure-localhost --ignore-certificate-errors' test.js --ssl 'key=path/to/key;cert=path/to/cert'

Passing pfx also worked
testcafe 'chrome --allow-insecure-localhost --ignore-certificate-errors' test.js --ssl pfx=path/to/pfx;

@lock
Copy link

lock bot commented Mar 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

6 participants