jaredwolff Did you load the certs onto your nRF910 Feather?
So, the following Nordic post mentioned in your article says that error 45 is usually related to bad client certs and explains how to create and install the certs. I think I did this correctly according to your instructions which are a different method than Nordic's:
I used the current version of LTE Link Monitor v1.1.8 to upload the following cut and pasted from the mosquitto server and entered tag 1234
ca.crt
nrf9160.crt
nrf9160.key
2020-10-27T21:27:42.894Z DEBUG modem << OK
2020-10-27T21:33:02.801Z INFO Updating CA certificate...
2020-10-27T21:33:02.803Z DEBUG modem >> AT%CMNG=0,1234,0,"-----BEGIN CERTIFICATE-----
2020-10-27T21:33:02.817Z DEBUG modem >> .....
2020-10-27T21:33:03.071Z DEBUG modem >> -----END CERTIFICATE-----"
2020-10-27T21:33:03.239Z DEBUG modem << OK
2020-10-27T21:33:03.241Z INFO Updating client certificate...
2020-10-27T21:33:03.244Z DEBUG modem >> AT%CMNG=0,1234,1,"-----BEGIN CERTIFICATE-----
2020-10-27T21:33:03.257Z DEBUG modem >> .....
2020-10-27T21:33:03.511Z DEBUG modem >> -----END CERTIFICATE-----"
2020-10-27T21:33:03.545Z DEBUG modem << OK
2020-10-27T21:33:03.546Z INFO Updating private key...
2020-10-27T21:33:03.547Z DEBUG modem >> AT%CMNG=0,1234,2,"-----BEGIN PRIVATE KEY-----
2020-10-27T21:33:03.560Z DEBUG modem >> .....
2020-10-27T21:33:03.936Z DEBUG modem >> -----END PRIVATE KEY-----"
2020-10-27T21:33:03.991Z DEBUG modem << OK
2020-10-27T21:33:03.992Z INFO Certificate update completed
2020-10-27T21:34:58.095Z DEBUG modem >> AT%CMNG=1
2020-10-27T21:34:58.122Z DEBUG modem << %CMNG: 0,6,"0606060606060606060606060606060606060606060606060606060606060606"
2020-10-27T21:34:58.127Z DEBUG modem << %CMNG: 1234,0,"0000000000000000000000000000000000000000000000000000000000000000"
2020-10-27T21:34:58.153Z DEBUG modem << %CMNG: 1234,1,"0101010101010101010101010101010101010101010101010101010101010101"
2020-10-27T21:34:58.169Z DEBUG modem << %CMNG: 1234,2,"0202020202020202020202020202020202020202020202020202020202020202"
2020-10-27T21:34:58.176Z DEBUG modem << %CMNG: 16842753,0,"0000000000000000000000000000000000000000000000000000000000000000"
2020-10-27T21:34:58.196Z DEBUG modem << %CMNG: 16842753,1,"0101010101010101010101010101010101010101010101010101010101010101"
2020-10-27T21:34:58.209Z DEBUG modem << %CMNG: 16842753,2,"0202020202020202020202020202020202020202020202020202020202020202"
jaredwolff Have you been able to connect using the mosquitto cli? That would be one of the first things I would try.
Some progress! I loaded the mosquitto clients on my Windows laptop.
Mosquitto client works on Windows Laptop to port 8885 TLS on BSD mosquitto server with nrf9160 client certs.
CMD Window 1
c:\Program Files\mosquitto>mosquitto_sub -h mosquitto1.my_domain.org -p 8885 -v -t 'test/topic' --cafile ca.crt --cert nrf9160.crt --key nrf9160.key
CMD Window 2
c:\Program Files\mosquitto>mosquitto_pub -h mosquitto1.my_domain.org -p 8885 -t 'test/topic' -m 'hello_there_again' -d --cafile ca.crt --cert nrf9160.crt --key nrf9160.key
Client mosq-IfHH00JFjJJcjw3HiC sending CONNECT
Client mosq-IfHH00JFjJJcjw3HiC received CONNACK (0)
Client mosq-IfHH00JFjJJcjw3HiC sending PUBLISH (d0, q0, r0, m1, ''test/topic'', ... (19 bytes))
Client mosq-IfHH00JFjJJcjw3HiC sending DISCONNECT
Back to CMD Window 1, hello_world_ message appears
c:\Program Files\mosquitto>mosquitto_sub -h mosquitto1.my_domain.org -p 8885 -v -t 'test/topic' --cafile ca.crt --cert nrf9160.crt --key nrf9160.key
'test/topic' 'hello_there_again'
TLS. I followed all the instructions for TLS. See config file snippets at bottom of this reply:
Yes.
On the Mosquitto Server:
root@mosquitto1:/usr/local/etc/mosquitto # sockstat -4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
nobody mosquitto 1790 3 tcp4 *:* *:*
nobody mosquitto 1790 6 tcp4 *:1883 *:*
nobody mosquitto 1790 8 tcp4 *:8885 *:*
root sshd 1235 3 tcp4 157.xxx.xxx.xxx:22 xx.xx.xx.xx:xxxxx
root sendmail 1099 3 tcp4 127.0.0.1:25 *:*
root sshd 1096 4 tcp4 *:22 *:*
root syslogd 622 7 udp4 *:514 *:*
On a Laptop Client:
tony@tony-ubuntu:~$ telnet mosquitto1.my_domain.org 8885
Trying 157.xxx.xxx.xxx...
Connected to mosquitto1._my__domain_.org.
tony@tony-ubuntu:~$ telnet mosquitto1.my_domain.org 1883
Trying 157.xxx.xxx.xxx...
Connected to mosquitto1.my_domain.org.
Misc Configuration info:
Droplet server: mosquitto.conf snippets
# Port to use for the default listener.
port 8885
# listener port-number [ip address/host name]
listener 1883
protocol mqtt
I had to change the 3 cert lines from /root/pki/... to /pki/... or the mosquitto service would not start. For example:
cafile /root/pki/ca.crt > cafile /pki/ca.crt
mqtt_simple prj.conf snippets
# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
# Application
CONFIG_MQTT_PUB_TOPIC="/my/publish/topic"
CONFIG_MQTT_SUB_TOPIC="/my/subscribe/topic"
CONFIG_MQTT_CLIENT_ID="nrf9160-feather"
CONFIG_MQTT_BROKER_HOSTNAME="mosquitto1.my_domain.org"
CONFIG_MQTT_BROKER_PORT=8885
CONFIG_SEC_TAG=1234
# Set the PDP context
CONFIG_LTE_PDP_CMD=y
CONFIG_LTE_PDP_CONTEXT="0,\"IP\",\"hologram\""
Kconfig snippets
config SEC_TAG
int "Security tag to use for the connection"
default 1234
config PEER_VERIFY
int "Peer verify parameter for mqtt_client"
default 1
help
Set to 0 for VERIFY_NONE, 1 for VERIFY_OPTIONAL, and 2 for VERIFY_REQUIRED.
main.c
Just under the includes:
#if defined(CONFIG_MQTT_LIB_TLS)
static sec_tag_t sec_tag_list[] = { CONFIG_SEC_TAG };
#endif /* defined(CONFIG_MQTT_LIB_TLS) */
client_init section
/* MQTT transport configuration */
#if defined(CONFIG_MQTT_LIB_TLS)
struct mqtt_sec_config *tls_config = &client->transport.tls.config;
client->transport.type = MQTT_TRANSPORT_SECURE;
tls_config->peer_verify = CONFIG_PEER_VERIFY;
tls_config->cipher_count = 0;
tls_config->cipher_list = NULL;
tls_config->sec_tag_count = ARRAY_SIZE(sec_tag_list);
tls_config->sec_tag_list = sec_tag_list;
tls_config->hostname = CONFIG_MQTT_BROKER_HOSTNAME;
client->transport.type = MQTT_TRANSPORT_SECURE;
#else
client->transport.type = MQTT_TRANSPORT_NON_SECURE;
#endif