Implement certificate checking.
This commit is contained in:
parent
cfb0c5f9bd
commit
4aaa754a4d
3 changed files with 86 additions and 39 deletions
16
tests/test.m
16
tests/test.m
|
@ -24,6 +24,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
#import <ObjOpenSSL/SSLInvalidCertificateException.h>
|
||||
|
||||
#import "XMPPConnection.h"
|
||||
#import "XMPPJID.h"
|
||||
|
@ -136,6 +137,21 @@ OF_APPLICATION_DELEGATE(AppDelegate)
|
|||
[conn sendStanza: pres];
|
||||
}
|
||||
|
||||
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn
|
||||
{
|
||||
@try {
|
||||
[conn checkCertificate];
|
||||
} @catch (SSLInvalidCertificateException *e) {
|
||||
OFString *answer;
|
||||
[of_stdout writeString: @"Couldn't verify certificate: "];
|
||||
[of_stdout writeFormat: @"%@\n", e];
|
||||
[of_stdout writeString: @"Do you want to continue [y/N]? "];
|
||||
answer = [of_stdin readLine];
|
||||
if (![answer hasPrefix: @"y"])
|
||||
@throw e;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection: (XMPPConnection*)conn
|
||||
didReceiveRosterItem: (XMPPRosterItem*)rosterItem
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue