diff --git a/Photino.Native/Exports.cpp b/Photino.Native/Exports.cpp index cd85b39..8a0119e 100644 --- a/Photino.Native/Exports.cpp +++ b/Photino.Native/Exports.cpp @@ -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); @@ -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) { diff --git a/Photino.Native/Photino.Linux.cpp b/Photino.Native/Photino.Linux.cpp index d4858b5..c6638e3 100644 --- a/Photino.Native/Photino.Linux.cpp +++ b/Photino.Native/Photino.Linux.cpp @@ -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; @@ -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)); @@ -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; diff --git a/Photino.Native/Photino.Mac.NavigationDelegate.h b/Photino.Native/Photino.Mac.NavigationDelegate.h new file mode 100644 index 0000000..f0329ad --- /dev/null +++ b/Photino.Native/Photino.Mac.NavigationDelegate.h @@ -0,0 +1,11 @@ +#ifdef __APPLE__ +#pragma once +#include "Photino.h" + +@interface NavigationDelegate: NSObject{ + @public + NSWindow * window; + Photino * photino; +} +@end +#endif \ No newline at end of file diff --git a/Photino.Native/Photino.Mac.NavigationDelegate.mm b/Photino.Native/Photino.Mac.NavigationDelegate.mm new file mode 100644 index 0000000..b6a892c --- /dev/null +++ b/Photino.Native/Photino.Mac.NavigationDelegate.mm @@ -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 \ No newline at end of file diff --git a/Photino.Native/Photino.Mac.mm b/Photino.Native/Photino.Mac.mm index 72b2f91..4bcc60f 100644 --- a/Photino.Native/Photino.Mac.mm +++ b/Photino.Native/Photino.Mac.mm @@ -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 #include "json.hpp" @@ -132,6 +133,7 @@ strcpy(_temporaryFilesPath, initParams->TemporaryFilesPath); } + _disableSslCertificateVerification = initParams->DisableSslCertificateVerification; _contextMenuEnabled = true; //not configurable on mac //initParams->ContextMenuEnabled; // _zoom = initParams->Zoom; @@ -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) @@ -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 @@ -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 @@ -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] diff --git a/Photino.Native/Photino.Windows.cpp b/Photino.Native/Photino.Windows.cpp index a975e27..0b5d09b 100644 --- a/Photino.Native/Photino.Windows.cpp +++ b/Photino.Native/Photino.Windows.cpp @@ -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; @@ -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; @@ -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; @@ -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(); if (startupString.length() > 0) diff --git a/Photino.Native/Photino.h b/Photino.Native/Photino.h index 7ceb500..0cfb414 100644 --- a/Photino.Native/Photino.h +++ b/Photino.Native/Photino.h @@ -18,6 +18,7 @@ typedef char *AutoString; #include #include #include +#include #endif #ifdef __linux__ @@ -114,7 +115,7 @@ struct PhotinoInitParams bool JavascriptClipboardAccessEnabled; bool MediaStreamEnabled; bool SmoothScrollingEnabled; - + bool DisableSslCertificateVerification; int Size; }; @@ -149,6 +150,7 @@ class Photino bool _javascriptClipboardAccessEnabled; bool _mediaStreamEnabled; bool _smoothScrollingEnabled; + bool _disableSslCertificateVerification; int _zoom; @@ -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); @@ -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(); diff --git a/README.md b/README.md index 150d927..c0c4532 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## NEXT PHOTINO FEATURES POLL +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, diff --git a/makefile b/makefile index 7f3e6f9..adb7fe0 100644 --- a/makefile +++ b/makefile @@ -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\ diff --git a/manual-arm-release/linux-arm64/Photino.Native.so b/manual-arm-release/linux-arm64/Photino.Native.so index 4c67003..c26df3a 100755 Binary files a/manual-arm-release/linux-arm64/Photino.Native.so and b/manual-arm-release/linux-arm64/Photino.Native.so differ diff --git a/manual-arm-release/win-arm64/Photino.Native.dll b/manual-arm-release/win-arm64/Photino.Native.dll index 736dc12..093d80f 100755 Binary files a/manual-arm-release/win-arm64/Photino.Native.dll and b/manual-arm-release/win-arm64/Photino.Native.dll differ