Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
3bb3e3e7
Commit
3bb3e3e7
authored
Feb 06, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SNI support, issue 171
parent
c2b12985
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
11 deletions
+39
-11
MQTTAsync.c
src/MQTTAsync.c
+12
-2
MQTTClient.c
src/MQTTClient.c
+12
-2
MQTTProtocolOut.c
src/MQTTProtocolOut.c
+3
-2
MQTTProtocolOut.h
src/MQTTProtocolOut.h
+3
-1
SSLSocket.c
src/SSLSocket.c
+6
-2
SSLSocket.h
src/SSLSocket.h
+3
-2
No files found.
src/MQTTAsync.c
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
6
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
* Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
* Ian Craggs - automatic reconnect and offline buffering (send while disconnected)
* Ian Craggs - fix for bug 472250
* Ian Craggs - fix for bug 472250
* Ian Craggs - fix for bug 486548
* Ian Craggs - fix for bug 486548
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
/**
/**
...
@@ -2708,7 +2709,16 @@ int MQTTAsync_connecting(MQTTAsyncs* m)
...
@@ -2708,7 +2709,16 @@ int MQTTAsync_connecting(MQTTAsyncs* m)
#if defined(OPENSSL)
#if defined(OPENSSL)
if
(
m
->
ssl
)
if
(
m
->
ssl
)
{
{
if
(
SSLSocket_setSocketForSSL
(
&
m
->
c
->
net
,
m
->
c
->
sslopts
)
!=
MQTTASYNC_SUCCESS
)
int
port
;
char
*
hostname
;
int
setSocketForSSLrc
=
0
;
hostname
=
MQTTProtocol_addressPort
(
m
->
serverURI
,
&
port
);
setSocketForSSLrc
=
SSLSocket_setSocketForSSL
(
&
m
->
c
->
net
,
m
->
c
->
sslopts
,
hostname
);
if
(
hostname
!=
m
->
serverURI
)
free
(
hostname
);
if
(
setSocketForSSLrc
!=
MQTTASYNC_SUCCESS
)
{
{
if
(
m
->
c
->
session
!=
NULL
)
if
(
m
->
c
->
session
!=
NULL
)
if
((
rc
=
SSL_set_session
(
m
->
c
->
net
.
ssl
,
m
->
c
->
session
))
!=
1
)
if
((
rc
=
SSL_set_session
(
m
->
c
->
net
.
ssl
,
m
->
c
->
session
))
!=
1
)
...
...
src/MQTTClient.c
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
5
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
* Ian Craggs - fix for bug 459791 - deadlock in WaitForCompletion for bad client
* Ian Craggs - fix for bug 459791 - deadlock in WaitForCompletion for bad client
* Ian Craggs - fix for bug 474905 - insufficient synchronization for subscribe, unsubscribe, connect
* Ian Craggs - fix for bug 474905 - insufficient synchronization for subscribe, unsubscribe, connect
* Ian Craggs - make it clear that yield and receive are not intended for multi-threaded mode (bug 474748)
* Ian Craggs - make it clear that yield and receive are not intended for multi-threaded mode (bug 474748)
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
/**
/**
...
@@ -834,7 +835,16 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
...
@@ -834,7 +835,16 @@ int MQTTClient_connectURIVersion(MQTTClient handle, MQTTClient_connectOptions* o
#if defined(OPENSSL)
#if defined(OPENSSL)
if
(
m
->
ssl
)
if
(
m
->
ssl
)
{
{
if
(
SSLSocket_setSocketForSSL
(
&
m
->
c
->
net
,
m
->
c
->
sslopts
)
!=
MQTTCLIENT_SUCCESS
)
int
port
;
char
*
hostname
;
int
setSocketForSSLrc
=
0
;
hostname
=
MQTTProtocol_addressPort
(
m
->
serverURI
,
&
port
);
setSocketForSSLrc
=
SSLSocket_setSocketForSSL
(
&
m
->
c
->
net
,
m
->
c
->
sslopts
,
hostname
);
if
(
hostname
!=
m
->
serverURI
)
free
(
hostname
);
if
(
setSocketForSSLrc
!=
MQTTCLIENT_SUCCESS
)
{
{
if
(
m
->
c
->
session
!=
NULL
)
if
(
m
->
c
->
session
!=
NULL
)
if
((
rc
=
SSL_set_session
(
m
->
c
->
net
.
ssl
,
m
->
c
->
session
))
!=
1
)
if
((
rc
=
SSL_set_session
(
m
->
c
->
net
.
ssl
,
m
->
c
->
session
))
!=
1
)
...
...
src/MQTTProtocolOut.c
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
6
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
* Ian Craggs - MQTT 3.1.1 support
* Ian Craggs - MQTT 3.1.1 support
* Rong Xiang, Ian Craggs - C++ compatibility
* Rong Xiang, Ian Craggs - C++ compatibility
* Ian Craggs - fix for bug 479376
* Ian Craggs - fix for bug 479376
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
/**
/**
...
@@ -103,7 +104,7 @@ int MQTTProtocol_connect(const char* ip_address, Clients* aClient, int MQTTVersi
...
@@ -103,7 +104,7 @@ int MQTTProtocol_connect(const char* ip_address, Clients* aClient, int MQTTVersi
#if defined(OPENSSL)
#if defined(OPENSSL)
if
(
ssl
)
if
(
ssl
)
{
{
if
(
SSLSocket_setSocketForSSL
(
&
aClient
->
net
,
aClient
->
sslopts
)
==
1
)
if
(
SSLSocket_setSocketForSSL
(
&
aClient
->
net
,
aClient
->
sslopts
,
addr
)
==
1
)
{
{
rc
=
SSLSocket_connect
(
aClient
->
net
.
ssl
,
aClient
->
net
.
socket
);
rc
=
SSLSocket_connect
(
aClient
->
net
.
ssl
,
aClient
->
net
.
socket
);
if
(
rc
==
-
1
)
if
(
rc
==
-
1
)
...
...
src/MQTTProtocolOut.h
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
4
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs - MQTT 3.1.1 support
* Ian Craggs - MQTT 3.1.1 support
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
#if !defined(MQTTPROTOCOLOUT_H)
#if !defined(MQTTPROTOCOLOUT_H)
...
@@ -29,6 +30,7 @@
...
@@ -29,6 +30,7 @@
#define DEFAULT_PORT 1883
#define DEFAULT_PORT 1883
char
*
MQTTProtocol_addressPort
(
const
char
*
uri
,
int
*
port
);
void
MQTTProtocol_reconnect
(
const
char
*
ip_address
,
Clients
*
client
);
void
MQTTProtocol_reconnect
(
const
char
*
ip_address
,
Clients
*
client
);
#if defined(OPENSSL)
#if defined(OPENSSL)
int
MQTTProtocol_connect
(
const
char
*
ip_address
,
Clients
*
acClients
,
int
ssl
,
int
MQTTVersion
);
int
MQTTProtocol_connect
(
const
char
*
ip_address
,
Clients
*
acClients
,
int
ssl
,
int
MQTTVersion
);
...
...
src/SSLSocket.c
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
6
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
* Ian Craggs - allow compilation for OpenSSL < 1.0
* Ian Craggs - allow compilation for OpenSSL < 1.0
* Ian Craggs - fix for bug #453883
* Ian Craggs - fix for bug #453883
* Ian Craggs - fix for bug #480363, issue 13
* Ian Craggs - fix for bug #480363, issue 13
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
/**
/**
...
@@ -543,7 +544,7 @@ exit:
...
@@ -543,7 +544,7 @@ exit:
}
}
int
SSLSocket_setSocketForSSL
(
networkHandles
*
net
,
MQTTClient_SSLOptions
*
opts
)
int
SSLSocket_setSocketForSSL
(
networkHandles
*
net
,
MQTTClient_SSLOptions
*
opts
,
char
*
hostname
)
{
{
int
rc
=
1
;
int
rc
=
1
;
...
@@ -569,6 +570,9 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts)
...
@@ -569,6 +570,9 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts)
}
}
if
((
rc
=
SSL_set_fd
(
net
->
ssl
,
net
->
socket
))
!=
1
)
if
((
rc
=
SSL_set_fd
(
net
->
ssl
,
net
->
socket
))
!=
1
)
SSLSocket_error
(
"SSL_set_fd"
,
net
->
ssl
,
net
->
socket
,
rc
);
SSLSocket_error
(
"SSL_set_fd"
,
net
->
ssl
,
net
->
socket
,
rc
);
if
((
rc
=
SSL_set_tlsext_host_name
(
net
->
ssl
,
hostname
))
!=
1
)
SSLSocket_error
(
"SSL_set_tlsext_host_name"
,
NULL
,
net
->
socket
,
rc
);
}
}
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
...
...
src/SSLSocket.h
View file @
3bb3e3e7
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
4
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
*
*
* Contributors:
* Contributors:
* Ian Craggs, Allan Stockdill-Mander - initial implementation
* Ian Craggs, Allan Stockdill-Mander - initial implementation
* Ian Craggs - SNI support
*******************************************************************************/
*******************************************************************************/
#if !defined(SSLSOCKET_H)
#if !defined(SSLSOCKET_H)
#define SSLSOCKET_H
#define SSLSOCKET_H
...
@@ -32,7 +33,7 @@
...
@@ -32,7 +33,7 @@
int
SSLSocket_initialize
();
int
SSLSocket_initialize
();
void
SSLSocket_terminate
();
void
SSLSocket_terminate
();
int
SSLSocket_setSocketForSSL
(
networkHandles
*
net
,
MQTTClient_SSLOptions
*
opts
);
int
SSLSocket_setSocketForSSL
(
networkHandles
*
net
,
MQTTClient_SSLOptions
*
opts
,
char
*
hostname
);
int
SSLSocket_getch
(
SSL
*
ssl
,
int
socket
,
char
*
c
);
int
SSLSocket_getch
(
SSL
*
ssl
,
int
socket
,
char
*
c
);
char
*
SSLSocket_getdata
(
SSL
*
ssl
,
int
socket
,
size_t
bytes
,
size_t
*
actual_len
);
char
*
SSLSocket_getdata
(
SSL
*
ssl
,
int
socket
,
size_t
bytes
,
size_t
*
actual_len
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment