Support for getting channel binding data
This commit is contained in:
parent
2c6ef4d969
commit
ace7324c7f
2 changed files with 31 additions and 0 deletions
|
@ -43,4 +43,5 @@
|
||||||
- (OFString*)privateKeyFile;
|
- (OFString*)privateKeyFile;
|
||||||
- (void)setCertificateFile: (OFString*)file;
|
- (void)setCertificateFile: (OFString*)file;
|
||||||
- (OFString*)certificateFile;
|
- (OFString*)certificateFile;
|
||||||
|
- (OFDataArray*)channelBindingDataWithType: (OFString*)type;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -25,12 +25,14 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#import <ObjFW/OFHTTPRequest.h>
|
#import <ObjFW/OFHTTPRequest.h>
|
||||||
|
#import <ObjFW/OFDataArray.h>
|
||||||
|
|
||||||
#import "SSLSocket.h"
|
#import "SSLSocket.h"
|
||||||
|
|
||||||
#import <ObjFW/OFAcceptFailedException.h>
|
#import <ObjFW/OFAcceptFailedException.h>
|
||||||
#import <ObjFW/OFConnectionFailedException.h>
|
#import <ObjFW/OFConnectionFailedException.h>
|
||||||
#import <ObjFW/OFInitializationFailedException.h>
|
#import <ObjFW/OFInitializationFailedException.h>
|
||||||
|
#import <ObjFW/OFInvalidArgumentException.h>
|
||||||
#import <ObjFW/OFNotConnectedException.h>
|
#import <ObjFW/OFNotConnectedException.h>
|
||||||
#import <ObjFW/OFOutOfRangeException.h>
|
#import <ObjFW/OFOutOfRangeException.h>
|
||||||
#import <ObjFW/OFReadFailedException.h>
|
#import <ObjFW/OFReadFailedException.h>
|
||||||
|
@ -277,4 +279,32 @@ static SSL_CTX *ctx;
|
||||||
{
|
{
|
||||||
OF_GETTER(certificateFile, YES)
|
OF_GETTER(certificateFile, YES)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (OFDataArray*)channelBindingDataWithType: (OFString*)type
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
char buffer[64];
|
||||||
|
OFDataArray *data;
|
||||||
|
|
||||||
|
if (![type isEqual: @"tls-unique"])
|
||||||
|
@throw [OFInvalidArgumentException newWithClass: isa
|
||||||
|
selector: _cmd];
|
||||||
|
|
||||||
|
if (SSL_session_reused(ssl) ^ !isListening) {
|
||||||
|
/*
|
||||||
|
* We are either client or the session has been resumed
|
||||||
|
* => we have sent the finished message
|
||||||
|
*/
|
||||||
|
length = SSL_get_finished(ssl, buffer, 64);
|
||||||
|
} else {
|
||||||
|
/* peer sent the finished message */
|
||||||
|
length = SSL_get_peer_finished(ssl, buffer, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
data = [OFDataArray dataArray];
|
||||||
|
[data addNItems: length
|
||||||
|
fromCArray: buffer];
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Reference in a new issue