Skip to content

Commit

Permalink
[Cocoa] ignore ssl errors for local http server by default
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0r committed Jan 10, 2025
1 parent fc4d948 commit 0a69a54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions examples/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import webview


if __name__ == '__main__':
# HTTP server is started automatically for local relative paths
webview.create_window('My first HTML5 application', 'assets/index.html')

# Server certificate is self signed so we need to ignore SSL errors
webview.settings['IGNORE_SSL_ERRORS'] = True
# HTTP server is started automatically for local relative paths
webview.start(ssl=True)
6 changes: 3 additions & 3 deletions webview/platforms/cocoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ class DownloadDelegate(AppKit.NSObject):
def download_decideDestinationUsingResponse_suggestedFilename_completionHandler_(self, download, decideDestinationUsingResponse, suggestedFilename, completionHandler):
save_dlg = AppKit.NSSavePanel.savePanel()
directory = Foundation.NSSearchPathForDirectoriesInDomains(
Foundation.NSDownloadsDirectory,
Foundation.NSUserDomainMask,
Foundation.NSDownloadsDirectory,
Foundation.NSUserDomainMask,
True)[0]
save_dlg.setDirectoryURL_(Foundation.NSURL.fileURLWithPath_(directory))
save_dlg.setNameFieldStringValue_(suggestedFilename)
Expand Down Expand Up @@ -187,7 +187,7 @@ def webView_didReceiveAuthenticationChallenge_completionHandler_(
from Security import SecTrustRef

# this allows any server cert
if webview_settings['IGNORE_SSL_ERRORS']:
if webview_settings['IGNORE_SSL_ERRORS'] or _state['ssl']:
credential = AppKit.NSURLCredential.credentialForTrust_(
challenge.protectionSpace().serverTrust()
)
Expand Down

0 comments on commit 0a69a54

Please sign in to comment.