Hallo zusammen,
heute habe ich eine sehr spezielle Frage. Und zwar geht es um das Anzeigen des Server Zertifikates bei einer HTTPS Verbindung in einem WebView (im Grunde wie in Safari).
Bisher schaut mein Code so aus (SecurityInterface/SFCertificatePanel.h ist implementiert).
Das Zertifikat wird als Fenster angezeigt, aber das Verhalten dieses Fensters ist seltsam. Es kann nur einmal geöffnet werden, danach muss die Demo App neu gestartet werden, damit das Zertifikat wieder eingeblendet werden.
Wo liegt hier der Fehler?
Alles anzeigen
Danke fürs' anschauen. Hoffe, jemand kann mir einen Tipp geben.
Eine Demo App mit dem Xcode Projekt (Objective-C | macOS) habe ich angehängt.
Anleiten lassen habe ich mich bisher hiervon: stackoverflow.com/questions/19…nformation-inside-cocoa-w
heute habe ich eine sehr spezielle Frage. Und zwar geht es um das Anzeigen des Server Zertifikates bei einer HTTPS Verbindung in einem WebView (im Grunde wie in Safari).
Bisher schaut mein Code so aus (SecurityInterface/SFCertificatePanel.h ist implementiert).
Das Zertifikat wird als Fenster angezeigt, aber das Verhalten dieses Fensters ist seltsam. Es kann nur einmal geöffnet werden, danach muss die Demo App neu gestartet werden, damit das Zertifikat wieder eingeblendet werden.
Wo liegt hier der Fehler?
Quellcode
- -(IBAction)ZeigeZertifikat:(id)sender
- {
- NSString *ZertifikatURL = [[NSUserDefaults standardUserDefaults] stringForKey:@"URL"];
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:ZertifikatURL]];
- // Create url connection and fire request
- NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- }
Quellcode
- -(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
- {
- if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
- // create trust from protection space
- SecTrustRef trustRef;
- int trustCertificateCount = (int)SecTrustGetCertificateCount(challenge.protectionSpace.serverTrust);
- NSMutableArray* trustCertificates = [[NSMutableArray alloc] initWithCapacity:trustCertificateCount];
- for (int i = 0; i < trustCertificateCount; i++) {
- SecCertificateRef trustCertificate = SecTrustGetCertificateAtIndex(challenge.protectionSpace.serverTrust, i);
- [trustCertificates addObject:(__bridge id) trustCertificate];
- }
- [[SFCertificatePanel sharedCertificatePanel] runModalForCertificates:trustCertificates showGroup:YES];
- }
- }
Danke fürs' anschauen. Hoffe, jemand kann mir einen Tipp geben.
Eine Demo App mit dem Xcode Projekt (Objective-C | macOS) habe ich angehängt.
Anleiten lassen habe ich mich bisher hiervon: stackoverflow.com/questions/19…nformation-inside-cocoa-w
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Scotch ()