"unsafely-treat-insecure-origin-as-secure" flag is not working on Chrome

Google Chrome

Google Chrome Problem Overview


I am using geo-location for a site running locally on my machine using HTTP on Chrome. However this does not work as I am running on HTTP as opposed to HTTPS.

On the console it says:

getCurrentPosition() and watchPosition() no longer work on insecure origins.
To use this feature, you should consider switching your application to a 
secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins 
for more details.

Accoriding to Deprecating Powerful Features on Insecure Origins its says to start chrome using --unsafely-treat-insecure-origin-as-secure="http://example.com" flag. The command I ran was similar to:

chrome.exe --unsafely-treat-insecure-origin-as-secure="http://hello.app"

However, the same error message still appears.

How can I fix this issue.

Google Chrome Solutions


Solution 1 - Google Chrome

None of the solutions worked for me.

I achieved this by following steps.

  1. Type chrome://flags/#unsafely-treat-insecure-origin-as-secure in the address bar.
  2. Add the origin which you need to treat as secure as shown in the below image.

enter image description here

  1. Relaunch chrome.

Solution 2 - Google Chrome

You must have missed some steps. Try to follow this

  1. Go to File Explorer then paste this to address bar >> C:\Program Files (x86)\Google\Chrome\Application (or just go to where you can find your chrome.exe)

  2. Right click chrome.exe > send to > Desktop (Create Shortcut)

  3. Go to your desktop then find the chrome shortcut you've created.

  4. Rename it to ChromeForTesting (this step is optional)

  5. Right click the shortcut, then Click Properties

  6. At the "Target", paste the following at the end of the link

    --user-data-dir=/tmp/foo --unsafely-treat-insecure-origin-as-secure=http://example.com

so Target should look somewhat similar to this

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=/tmp/foo --unsafely-treat-insecure-origin-as-secure=http://example.com

7. Click Ok.. 8. During testing close all of your opened google chrome browser. Then double click ChromeForTesting shortcut (the one you've created), when a prompt appears, just click ok..


EDIT: If the steps above does not work for you, you might be using Chrome V63, update it to V64 above cause this flag is messed up in V63.

P.S. If it's still not working follow these extra steps

  1. At your drive C, create a folder and name it "ChromeTempFiles".

  2. Then in your --user-data-dir= you change the value into "C:\ChromeTempFiles"

  3. Add these to your target as well

    --allow-running-insecure-content --reduce-security-for-testing

so your target should look like this now

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=C:\ChromeTempFiles --unsafely-treat-insecure-origin-as-secure=http://example.com --allow-running-insecure-content --reduce-security-for-testing

Solution 3 - Google Chrome

You should also use a temproary fresh profile for that session. something like this:

chrome.exe --user-data-dir=/test/only/profile/dir --unsafely-treat-insecure-origin-as-secure="http://example.com"

Solution 4 - Google Chrome

Just an update to this for Chrome 70. This works perfectly

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=C:\ChromeTempFiles --allow-running-insecure-content

Now does anybody know if there is an equivalent for firefox?

Solution 5 - Google Chrome

For Chromium 44 use

--unsafety-treat-insecure-origin-as-secure=http://192.168.0.101:3000

instead

--unsafely-treat-insecure-origin-as-secure=http://192.168.0.101:3000

See that bug

Solution 6 - Google Chrome

In Google Chrome, you simply type into the address bar, "chrome://flags", and search for, "--unsafely-treat-insecure-origin-as-secure", enable that flag, and enter into the field below (multiples may be entered separated by a comma) the domain you wish to treat as secure. This may or may not compromise your security, but I would assume not as getCurrentPosition() and watchPosition() are somewhat recently deprecated features. this works for publicly served domains, as well.

Solution 7 - Google Chrome

With Chrome 79 this setting doesn't work no matter what.

What I ended up doing was to configure the domain on a VPS to show some test webpage and then generate a valid certificate for it using Let's Encrypt's certbot.

Then I copied that certificate to my machine and it's now valid.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYahya UddinView Question on Stackoverflow
Solution 1 - Google ChromeKartik SharmaView Answer on Stackoverflow
Solution 2 - Google ChromeJkAlombroView Answer on Stackoverflow
Solution 3 - Google ChromeaelbatalView Answer on Stackoverflow
Solution 4 - Google ChromevinyllickerView Answer on Stackoverflow
Solution 5 - Google ChromeNikolay MakhoninView Answer on Stackoverflow
Solution 6 - Google Chromejim owensView Answer on Stackoverflow
Solution 7 - Google ChromeLachoTomovView Answer on Stackoverflow