Add basic STARTTLS support
This commit is contained in:
parent
954e3e1dda
commit
54ffeac46b
2 changed files with 26 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
all:
|
all:
|
||||||
objfw-compile -Wall --lib 0.0 -o objxmpp *.m \
|
objfw-compile -Wall --lib 0.0 -o objxmpp *.m \
|
||||||
`pkg-config --cflags --libs libidn`
|
`pkg-config --cflags --libs libidn` -lobjgnutls
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.so *.dylib *.dll
|
rm -f *.o *.so *.dylib *.dll
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include <stringprep.h>
|
#include <stringprep.h>
|
||||||
#include <idna.h>
|
#include <idna.h>
|
||||||
|
|
||||||
|
#import <ObjGnuTLS/ObjGnuTLS.h>
|
||||||
|
|
||||||
#import "XMPPConnection.h"
|
#import "XMPPConnection.h"
|
||||||
#import "XMPPSCRAMAuth.h"
|
#import "XMPPSCRAMAuth.h"
|
||||||
#import "XMPPPLAINAuth.h"
|
#import "XMPPPLAINAuth.h"
|
||||||
|
@ -37,6 +39,7 @@
|
||||||
#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
|
#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
|
||||||
#define NS_CLIENT @"jabber:client"
|
#define NS_CLIENT @"jabber:client"
|
||||||
#define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
|
#define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
|
||||||
|
#define NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls"
|
||||||
#define NS_STREAM @"http://etherx.jabber.org/streams"
|
#define NS_STREAM @"http://etherx.jabber.org/streams"
|
||||||
|
|
||||||
@implementation XMPPConnection
|
@implementation XMPPConnection
|
||||||
|
@ -271,6 +274,9 @@
|
||||||
{
|
{
|
||||||
OFArray *mechs = [elem elementsForName: @"mechanisms"
|
OFArray *mechs = [elem elementsForName: @"mechanisms"
|
||||||
namespace: NS_SASL];
|
namespace: NS_SASL];
|
||||||
|
OFXMLElement *starttls = [elem
|
||||||
|
elementsForName: @"starttls"
|
||||||
|
namespace: NS_STARTTLS].firstObject;
|
||||||
OFXMLElement *bind = [elem elementsForName: @"bind"
|
OFXMLElement *bind = [elem elementsForName: @"bind"
|
||||||
namespace: NS_BIND].firstObject;
|
namespace: NS_BIND].firstObject;
|
||||||
|
|
||||||
|
@ -292,6 +298,10 @@
|
||||||
|
|
||||||
if (bind != nil)
|
if (bind != nil)
|
||||||
[self _sendResourceBind];
|
[self _sendResourceBind];
|
||||||
|
|
||||||
|
if (starttls != nil)
|
||||||
|
[self sendStanza: [OFXMLElement elementWithName: @"starttls"
|
||||||
|
namespace: NS_STARTTLS]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)elementBuilder: (OFXMLElementBuilder*)b
|
- (void)elementBuilder: (OFXMLElementBuilder*)b
|
||||||
|
@ -307,6 +317,21 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([elem.namespace isEqual: NS_STARTTLS]) {
|
||||||
|
if ([elem.name isEqual: @"proceed"]) {
|
||||||
|
/* FIXME: Catch errors here */
|
||||||
|
sock = [[GTLSSocket alloc] initWithSocket: sock];
|
||||||
|
|
||||||
|
/* Stream restart */
|
||||||
|
[mechanisms release];
|
||||||
|
mechanisms = [[OFMutableArray alloc] init];
|
||||||
|
parser.delegate = self;
|
||||||
|
[self _startStream];
|
||||||
|
} else if ([elem.name isEqual: @"failure"])
|
||||||
|
/* TODO: Find/create an exception to throw here */
|
||||||
|
@throw [OFException newWithClass: isa];
|
||||||
|
}
|
||||||
|
|
||||||
if ([elem.namespace isEqual: NS_SASL]) {
|
if ([elem.namespace isEqual: NS_SASL]) {
|
||||||
if ([elem.name isEqual: @"challenge"]) {
|
if ([elem.name isEqual: @"challenge"]) {
|
||||||
OFXMLElement *responseTag;
|
OFXMLElement *responseTag;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue