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

Disable ssl certificate verification #120

Merged
merged 25 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a788e96
Update README.md
ottodobretsberger Feb 3, 2023
94c0593
Merge pull request #100 from tryphotino/debug
MikeYeager Feb 3, 2023
447d443
Update azure-pipelines-photino.native-prod.yml for Azure Pipelines
MikeYeager Feb 3, 2023
f91e94d
Update azure-pipelines-photino.native-prod.yml for Azure Pipelines
MikeYeager Feb 3, 2023
66d7660
Merge pull request #101 from tryphotino/debug
MikeYeager Feb 3, 2023
24be1c5
Update azure-pipelines-photino.native-dev.yml for Azure Pipelines
MikeYeager Feb 3, 2023
cda0370
Merge branch 'debug'
philippjbauer Apr 13, 2023
94a9ada
Update prod pipeline to use new configuration
philippjbauer Apr 13, 2023
480ba6b
Merge branch 'debug'
philippjbauer Nov 2, 2023
73e13a6
Merge branch 'debug'
philippjbauer Nov 2, 2023
e66a8bc
Update azure-pipelines-photino.native-dev.yml for Azure Pipelines
philippjbauer Nov 2, 2023
c494f35
Update azure-pipelines-photino.native-dev.yml for Azure Pipelines
philippjbauer Nov 2, 2023
0e2f805
Update azure-pipelines-photino.native-dev.yml for Azure Pipelines
philippjbauer Nov 2, 2023
f2f5c58
Add manually compiled ARM64 versions of current master
philippjbauer Nov 2, 2023
eacd3df
Copy manual ARM64 releases
philippjbauer Nov 2, 2023
aa29b5e
Add WebView2Loader to WindowsArm64Artifact
philippjbauer Nov 2, 2023
77a646e
Update Master / Production Release Pipeline
philippjbauer Nov 2, 2023
87dada4
Merge branch 'debug'
philippjbauer Nov 9, 2023
9e33f78
Merge branch 'debug'
philippjbauer Nov 9, 2023
c85829b
add disable ssl certificate verification flag
jammerxd Jan 4, 2024
5a4c9d8
update exports.
jammerxd Jan 4, 2024
0c6ce00
added EXPORT getter.
jammerxd Jan 4, 2024
26e3adc
update include for Apple
jammerxd Jan 4, 2024
a6f9058
typo in Photino.Linux.cpp, update arm release of windows
jammerxd Jan 4, 2024
5560b8b
update linux-arm-x64
jammerxd Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Photino.Native/Exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ extern "C"
instance->GetMinimized(isMinimized);
}

EXPORTED void Photino_GetSslCertificateVerificationDisabled(Photino* instance, bool *disabled)
{
instance->GetSslCertificateVerificationDisabled(disabled);
}

EXPORTED void Photino_GetPosition(Photino* instance, int* x, int* y)
{
instance->GetPosition(x, y);
Expand Down Expand Up @@ -245,6 +250,11 @@ extern "C"
{
instance->SetZoom(zoom);
}

EXPORTED void Photino_SetSslCertificateVerificationDisabled(Photino* instance, bool disabled)
{
instance->SetSslCertificateVerificationDisabled(disabled);
}

EXPORTED void Photino_ShowNotification(Photino* instance, AutoString title, AutoString body)
{
Expand Down
22 changes: 22 additions & 0 deletions Photino.Native/Photino.Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Photino::Photino(PhotinoInitParams *initParams) : _webview(nullptr)
_javascriptClipboardAccessEnabled = initParams->JavascriptClipboardAccessEnabled;
_mediaStreamEnabled = initParams->MediaStreamEnabled;
_smoothScrollingEnabled = initParams->SmoothScrollingEnabled;
SetSslCertificateVerificationDisabled(initParams->DisableSslCertificateVerification);

_zoom = initParams->Zoom;
_minWidth = initParams->MinWidth;
Expand Down Expand Up @@ -357,6 +358,11 @@ void Photino::GetSmoothScrollingEnabled(bool* enabled)
*enabled = this->_smoothScrollingEnabled;
}

void Photino::GetSslCertificateVerificationDisabled(bool* enabled)
{
*enabled = this->_disableSslCertificateVerification;
}

void Photino::GetMaximized(bool *isMaximized)
{
*isMaximized = gtk_window_is_maximized(GTK_WINDOW(_window));
Expand Down Expand Up @@ -577,6 +583,22 @@ void Photino::SetResizable(bool resizable)
gtk_window_set_resizable(GTK_WINDOW(_window), resizable);
}

void Photino::SetSslCertificateVerificationDisabled(bool disabled)
{
_disableSslCertificateVerification = disabled;
WebKitWebContext* context = webkit_web_context_get_default();
WebKitWebsiteDataManager* manager = webkit_web_context_get_website_data_manager(context);

if(disabled)
{
webkit_website_data_manager_set_tls_errors_policy(manager,WEBKIT_TLS_ERRORS_POLICY_IGNORE);
}
else
{
webkit_website_data_manager_set_tls_errors_policy(manager,WEBKIT_TLS_ERRORS_POLICY_FAIL);
}
}

void Photino::SetMinSize(int width, int height)
{
_hints.min_width = width;
Expand Down
11 changes: 11 additions & 0 deletions Photino.Native/Photino.Mac.NavigationDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifdef __APPLE__
#pragma once
#include "Photino.h"

@interface NavigationDelegate: NSObject<WKNavigationDelegate>{
@public
NSWindow * window;
Photino * photino;
}
@end
#endif
21 changes: 21 additions & 0 deletions Photino.Native/Photino.Mac.NavigationDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifdef __APPLE__
#import "Photino.Mac.NavigationDelegate.h"

@implementation NavigationDelegate : NSObject

- (void)webView:(WKWebView *)webView
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {
bool disableSslCertificateVerification = false;
photino->GetSslCertificateVerificationDisabled(&disableSslCertificateVerification);
if(disableSslCertificateVerification)
{
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
CFDataRef exceptions = SecTrustCopyExceptions(serverTrust);
CFRelease(exceptions);
completionHandler(NSURLSessionAuthChallengeUseCredential,[NSURLCredential credentialForTrust:serverTrust]);
}
}

@end
#endif
18 changes: 18 additions & 0 deletions Photino.Native/Photino.Mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Photino.Mac.UiDelegate.h"
#include "Photino.Mac.UrlSchemeHandler.h"
#include "Photino.Mac.NSWindowBorderless.h"
#include "Photino.Mac.NavigationDelegate.h"
#include <vector>

#include "json.hpp"
Expand Down Expand Up @@ -132,6 +133,7 @@
strcpy(_temporaryFilesPath, initParams->TemporaryFilesPath);
}

_disableSslCertificateVerification = initParams->DisableSslCertificateVerification;
_contextMenuEnabled = true; //not configurable on mac //initParams->ContextMenuEnabled;
// _zoom = initParams->Zoom;

Expand All @@ -146,6 +148,7 @@
_minimizedCallback = (MinimizedCallback)initParams->MinimizedHandler;
_restoredCallback = (RestoredCallback)initParams->RestoredHandler;
_customSchemeCallback = (WebResourceRequestedCallback)initParams->CustomSchemeHandler;


//copy strings from the fixed size array passed, but only if they have a value.
for (int i = 0; i < 16; ++i)
Expand Down Expand Up @@ -425,6 +428,11 @@
*resizable = (([_window styleMask] & NSWindowStyleMaskResizable) == NSWindowStyleMaskResizable);
}

void Photino::GetSslCertificateVerificationDisabled(bool* enabled)
{
*enabled = this->_disableSslCertificateVerification;
}

unsigned int Photino::GetScreenDpi()
{
//not supported on macOS - _window's devices collection does have dpi
Expand Down Expand Up @@ -623,6 +631,11 @@
}
}

void Photino::SetSslCertificateVerificationDisabled(bool disabled)
{
_disableSslCertificateVerification = disabled;
}

void Photino::SetPosition(int x, int y)
{
// Currently assuming window is on monitor 0
Expand Down Expand Up @@ -866,11 +879,16 @@ void EnsureInvoke(dispatch_block_t block)
uiDelegate->window = _window;
uiDelegate->webMessageReceivedCallback = _webMessageReceivedCallback;

NavigationDelegate *navDelegate = [[[NavigationDelegate alloc] init] autorelease];
navDelegate->photino = this;
navDelegate->window = _window;

[userContentController
addScriptMessageHandler: uiDelegate
name:@"photinointerop"];

_webview.UIDelegate = uiDelegate;
_webview.navigationDelegate = navDelegate;

// TODO: Replace with WindowDelegate
[[NSNotificationCenter defaultCenter]
Expand Down
13 changes: 13 additions & 0 deletions Photino.Native/Photino.Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Photino::Photino(PhotinoInitParams* initParams)
_javascriptClipboardAccessEnabled = initParams->JavascriptClipboardAccessEnabled;
_mediaStreamEnabled = initParams->MediaStreamEnabled;
_smoothScrollingEnabled = initParams->SmoothScrollingEnabled;
_disableSslCertificateVerification = initParams->DisableSslCertificateVerification;

_zoom = initParams->Zoom;
_minWidth = initParams->MinWidth;
Expand Down Expand Up @@ -508,6 +509,11 @@ void Photino::GetSmoothScrollingEnabled(bool* enabled)
*enabled = this->_smoothScrollingEnabled;
}

void Photino::GetSslCertificateVerificationDisabled(bool* enabled)
{
*enabled = this->_disableSslCertificateVerification;
}

AutoString Photino::GetIconFileName()
{
return this->_iconFileName;
Expand Down Expand Up @@ -675,6 +681,11 @@ void Photino::SetMaximized(bool maximized)
ShowWindow(_hWnd, SW_NORMAL);
}

void Photino::SetSslCertificateVerificationDisabled(bool disabled)
{
_disableSslCertificateVerification = disabled;
}

void Photino::SetMaxSize(int width, int height)
{
_maxWidth = width;
Expand Down Expand Up @@ -843,6 +854,8 @@ void Photino::AttachWebView()
startupString += L"--disable-smooth-scrolling ";
if (_browserControlInitParameters != NULL)
startupString += _browserControlInitParameters; //e.g.--hide-scrollbars
if(_disableSslCertificateVerification)
startupString += L"--ignore-certificate-errors ";

auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
if (startupString.length() > 0)
Expand Down
6 changes: 5 additions & 1 deletion Photino.Native/Photino.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef char *AutoString;
#include <WebKit/WebKit.h>
#include <WebKit/WKWebView.h>
#include <WebKit/WKWebViewConfiguration.h>
#include <Security/SecTrust.h>
#endif

#ifdef __linux__
Expand Down Expand Up @@ -114,7 +115,7 @@ struct PhotinoInitParams
bool JavascriptClipboardAccessEnabled;
bool MediaStreamEnabled;
bool SmoothScrollingEnabled;

bool DisableSslCertificateVerification;
int Size;
};

Expand Down Expand Up @@ -149,6 +150,7 @@ class Photino
bool _javascriptClipboardAccessEnabled;
bool _mediaStreamEnabled;
bool _smoothScrollingEnabled;
bool _disableSslCertificateVerification;

int _zoom;

Expand Down Expand Up @@ -259,6 +261,7 @@ class Photino
AutoString GetTitle();
void GetTopmost(bool *topmost);
void GetZoom(int *zoom);
void GetSslCertificateVerificationDisabled(bool* enabled);

void NavigateToString(AutoString content);
void NavigateToUrl(AutoString url);
Expand All @@ -279,6 +282,7 @@ class Photino
void SetTitle(AutoString title);
void SetTopmost(bool topmost);
void SetZoom(int zoom);
void SetSslCertificateVerificationDisabled(bool disabled);

void ShowNotification(AutoString title, AutoString message);
void WaitForExit();
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## <span>NEXT PHOTINO FEATURES POLL</span>
Hello Photino Community! Please take a moment to check out our Photino poll and vote on the next features to be implemented, here:

[PHOTINO POLL](https://github.com/tryphotino/photino.NET/discussions/117)


# Build native, cross-platform desktop apps

Photino is a lightweight open-source framework for building native,
Expand Down
2 changes: 2 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ build-photino-mac-universal:
-framework Cocoa\
-framework WebKit\
-framework UserNotifications\
-framework Security\
$(SRC)/Photino.Mac.AppDelegate.mm\
$(SRC)/Photino.Mac.UiDelegate.mm\
$(SRC)/Photino.Mac.NavigationDelegate.mm\
$(SRC)/Photino.Mac.UrlSchemeHandler.mm\
$(SRC)/Photino.Mac.NSWindowBorderless.mm\
$(SRC)/Photino.Mac.Dialog.mm\
Expand Down
Binary file modified manual-arm-release/linux-arm64/Photino.Native.so
Binary file not shown.
Binary file modified manual-arm-release/win-arm64/Photino.Native.dll
Binary file not shown.