Skip to content

Commit

Permalink
Better ssl checking
Browse files Browse the repository at this point in the history
  • Loading branch information
timhonders committed May 2, 2019
1 parent b8fe2a3 commit a2d0167
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void initialize(ReadableMap config) {
this.factory.setRequestedHeartbeat(10);

try {
if (this.config.getInt("port") == 5671) {
if (this.config.getBoolean("ssl")) {
this.factory.useSslProtocol();
}
} catch(Exception e) {
Expand Down
14 changes: 9 additions & 5 deletions ios/RCTReactNativeRabbitMq/RabbitMqConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ @implementation RabbitMqConnection
{

RabbitMqDelegateLogger *delegate = [[RabbitMqDelegateLogger alloc] initWithBridge:self.bridge];

if(self.config[@"port"] == 5671) {
NSString *uri = [NSString stringWithFormat:@"amqps://%@:%@@%@:%@/%@", self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];
} else {
NSString *uri = [NSString stringWithFormat:@"amqp://%@:%@@%@:%@/%@", self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];

NSString *protocol = @"amqp";

Boolean ssl = self.config[@"ssl"];
if (ssl) {
protocol = @"amqps";
}

NSString *uri = [NSString stringWithFormat:@"%@://%@:%@@%@:%@/%@", protocol, self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];


self.connection = [[RMQConnection alloc] initWithUri:uri
channelMax:@65535
frameMax:@(RMQFrameMax)
Expand Down

0 comments on commit a2d0167

Please sign in to comment.