Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Mixed Messages About HTTPS, browser crashes.

Post Reply
Pcrepair
Posts: 10
Joined: Tue Sep 27, 2022 5:09 pm

Mixed Messages About HTTPS, browser crashes.

Post by Pcrepair »

Good day salvadordf

CEF4Delphi-105-based browser (TChromium) loads a page on https,
which contains a link to a resource from another site (http protocol).

As a result, the browser crashes and displays a message in the log:
Mixed Content: The page at 'https://oursite.company.com/' was loaded over HTTPS, but requested an insecure element 'http://site.com/pic.jpg'. This request was automatically upgraded to HTTPS, For more information see {https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html}

there is also an indication of a glitch in the

Code: Select all

unit Vcl.Controls;
... 
procedure TWinControl.DefaultHandler(var Message);
...
 Result := CallWindowProc(FDefWndProc, WindowHandle, Msg, WParam, LParam); //error here
...
end;
Trying to control the parameters did not work

Code: Select all

procedure CreateGlobalCEFApp;
begin
  GlobalCEFApp := TCefApplication.Create;
  GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_OnProcessMessageReceived;

  GlobalCEFApp.IgnoreCertificateErrors := True;
  GlobalCEFApp.DisableWebSecurity := True;
  GlobalCEFApp.DisableSafeBrowsing := True;
end;
If possible, please point to a way to block this crash, or a solution.

Thank you.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Mixed Messages About HTTPS, browser crashes.

Post by salvadordf »

I would try several things :
  • Update to the latest CEF4Delphi version. That crash shouldn't happen and perhaps it was fixed in later CEF versions.
  • Set GlobalCEFApp.TreatInsecureOriginAsSecure to 'site.com' (The insecure domain).
The GlobalCEFApp properties must be set before the GlobalCEFApp.StartMainProcess call.

Please, try to reproduce that error with the official CEF sample application :
https://cef-builds.spotifycdn.com/cef_binary_106.1.1%2Bg5891c70%2Bchromium-106.0.5249.119_windows64_client.tar.bz2

Can you provide the URL that is causing this issue?
Pcrepair
Posts: 10
Joined: Tue Sep 27, 2022 5:09 pm

Re: Mixed Messages About HTTPS, browser crashes.

Post by Pcrepair »

salvadordf, Thanks for the attention.

>>Update to the latest CEF4Delphi version.
CEF4Delphi-105 is in use

>>Set GlobalCEFApp.TreatInsecureOriginAsSecure to 'site.com'
GlobalCEFApp.TreatInsecureOriginAsSecure := ' https://03lip.ru/ '; doesn't work

>>The GlobalCEFApp properties must be set before the GlobalCEFApp.StartMainProcess call.
performed, had no effect

cef_binary_106.1.1+g5891c70+chromium-106.0.5249.119_windows64_client (perhaps there is a source code for review?)
displays a message about the record in console.log, but there is no failure (I attach the logs), after OK the page loads.
This is what I need, but where is my error?
Thank you.

10:25 04.11.2022
P.S. Everything works, it is necessary to use

Code: Select all

procedure TMain.crmConsoleMessage(Sender: TObject; const browser: ICefBrowser; level: Cardinal;
  const message, source: ustring; line: Integer; out Result: Boolean);
begin  (*shit was here!!!*)
  // In this event we receive the message with the name and value of a DOM node
  // from the render process.
  // This event may receive many other messages but we identify our message
  // thanks to the preamble.
  // The we set MsgContents with the rest of the message and send a
  // MINIBROWSER_SHOWMESSAGE message to show MsgContents in the main thread safely.
  // This and many other TChromium events are executed in a CEF thread. The VCL
  // should be used only in the main thread and we use a message and a field
  // protected by a synchronization object to call showmessage safely.
  if (length(message) > 0) and (copy(message, 1, length(CONSOLE_MSG_PREAMBLE)) = CONSOLE_MSG_PREAMBLE) then
  begin
    MsgContents := copy(message, succ(length(CONSOLE_MSG_PREAMBLE)), length(message));

    if (length(MsgContents) = 0) then
      MsgContents := 'There was an error reading the search box information'
    else
      MsgContents := 'Search box information: ' + quotedstr(MsgContents);

    PostMessage(Handle, MINIBROWSER_SHOWMESSAGE, 0, 0);

    Result := True;
  end;
end;
and all dependencies. The consequence of simplifying the code.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Mixed Messages About HTTPS, browser crashes.

Post by salvadordf »

if the latest official CEF sample application works fine then install the latest CEF4Delphi version from the master branch :
https://github.com/salvadordf/CEF4Delphi/archive/master.zip

The master branch includes Chromium 106.0.5249.119 like the official CEF sample application.
Post Reply