Hello Michal,
Based on the documentation and on some samples that I saw in the internet these two files is needed for the MQTT TLS handshake on this device.
There are different options depending on your use case and capabilities but you can generate Client certificate and Client Key certificate for PEM-based clients by using the sample command below
openssl req -x509 -newkey rsa:2048 -keyout user_key.pem -out client.pem -nodes
I have created the sample certificates for testing purpose and updated the AT commands sequence, please give a new try by using the commands below.
# Remove "isrgrootx1.pem" file previous created on the device
AT+QFDEL="isrgrootx1.pem"
# Set the MQTT SSL mode and/or SSL context index
# +QMTCFG: "ssl",<client_idx>[,<SSL_enable>[,<ctxindex>]]
AT+QMTCFG="ssl",0,1,2
# Upload/Store CA certificate to UFS
# In HiveMQ Cloud you need to specify a trusted certificate parameter
# You can download this cert from https://letsencrypt.org/certs/isrgrootx1.pem
# +QFUPL: <filename>[,<file_size>[,<timeout>[,<ackmode>]]]
AT+QFUPL="cacert.pem",1938,100
<Input the cacert.pem data, make sure the bytes size match with key length>
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0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zVc
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
-----END CERTIFICATE-----
# Upload/Store CC certificate and CK certificate to UFS
# Generate Client certificate and Client Key certificate for PEM-based clients
# openssl req -x509 -newkey rsa:2048 -keyout user_key.pem -out client.pem -nodes
# +QFUPL: <filename>[,<file_size>[,<timeout>[,<ackmode>]]]
AT+QFUPL="client.pem",1093,100
<Input the client.pem data, make sure the bytes size match with key length>
-----BEGIN CERTIFICATE-----
MIIC+zCCAeOgAwIBAgIUVYH1TOgwaUf3nNxJ8RMnqvR8yZ8wDQYJKoZIhvcNAQEL
BQAwDTELMAkGA1UEBhMCVVMwHhcNMjMwMzEyMTkyMzM2WhcNMjMwNDExMTkyMzM2
WjANMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AJpTb41b3wF7CnPqPeVCaoiI6hJZaB5xvaSiAzhwsYlcjHMovdFDLIIhsL/a4Kdu
kzQxJ9CziClFxlgKl051AxQguvmiz94fsAZX/KFVB2xNvYgYgp5kUAr8+EUYtmyT
/C7IZ/rtRdqsbyzZ5HF+YY3/5Msoya/Hb2QmL7Ju5jnLfAEk/IPjTHo+VZ49XzWG
Je4301ieNemndyQlsyrXTpbhV4RrTEfBhJBhC/Xa5KCyhLx/V8QXMvbSnf5t8f62
+2C6mDmFstSpWeHf79igs53Wfe6EdiwheeMVNaa5Xdf6VzdVbJjiswNiVklizVvZ
bRFTfmTzWTeHG+3hw46DewcCAwEAAaNTMFEwHQYDVR0OBBYEFN+QIkE8bKy5xWBM
5Hj9nhX7w/3lMB8GA1UdIwQYMBaAFN+QIkE8bKy5xWBM5Hj9nhX7w/3lMA8GA1Ud
EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHwEpFMtEVl74Xqq17lLK1DW
x5ngt1TLm7FAKgM+lITQzDrdxamqij47EcaFVshQPeFQE12W62PsVpy9HHGISSbl
n51Gev+09mgDNPeeMVx7LYY3wTT1tt8BG+jxKOU6zxZMnkEXmLlFqII8qUaXeTiz
GyuoE1xGGAjwhhdhzXzHz46LBDJzAReDMRqJMxBr7IpFSEE1plu3Cl9ryKRsoxgq
dPNOu/QzSwcLdT/EfHlRsl0V7E2zUO+VTjU3wZ/wJoQ56/84xC2oGgwNBOXJQSA6
4ZJEAtCKU9MzixMp95GKx+yBfqR91EYydipUrexiBbcwEIg5UCiIQVC3M+F7GSU=
-----END CERTIFICATE-----
AT+QFUPL="user_key.pem",1703,100
<Input the user_key.pem data, make sure the bytes size match with key length>
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCaU2+NW98Bewpz
6j3lQmqIiOoSWWgecb2kogM4cLGJXIxzKL3RQyyCIbC/2uCnbpM0MSfQs4gpRcZY
CpdOdQMUILr5os/eH7AGV/yhVQdsTb2IGIKeZFAK/PhFGLZsk/wuyGf67UXarG8s
2eRxfmGN/+TLKMmvx29kJi+ybuY5y3wBJPyD40x6PlWePV81hiXuN9NYnjXpp3ck
JbMq106W4VeEa0xHwYSQYQv12uSgsoS8f1fEFzL20p3+bfH+tvtgupg5hbLUqVnh
3+/YoLOd1n3uhHYsIXnjFTWmuV3X+lc3VWyY4rMDYlZJYs1b2W0RU35k81k3hxvt
4cOOg3sHAgMBAAECggEAQq6JlVVcgvnEtvhAPVbYzF0IctxB4mG4FTJR3OnItHcS
UtIITqrNSP9ArW1oQ8BCB7uznfhs/ZRiEvmkjih+J4zK7YGderdLajpLdPRWDER9
ABjDG6hxc4YBym1WqYy52wc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FDLotuIH4PZ
LZD8cokwUAAWhYgtX8cRLw==
-----END PRIVATE KEY-----
# Configure CA certificate, CC certificate and CK certificate
# +QSSLCFG: "cacert",<SSL_ctxID>,<cacertpath>
# +QSSLCFG: "clientcert",<SSL_ctxID>,<client_cert_path>
# +QSSLCFG: "clientkey",<SSL_ctxID>,<client_key_path>
AT+QSSLCFG="cacert",2,"cacert.pem"
AT+QSSLCFG="clientcert",2,"client.pem"
AT+QSSLCFG="clientkey",2,"user_key.pem"
# Enable Server Name Indication (SNI) extension. Required for HiveMQ Cloud Broker (Free and Pay As You Go)
# Whether to enable server name indication feature, currently, the only server names supported are DNS hostnames.
# 0 - Disable server name indication
# 1 - Enable server name indication
# +QSSLCFG: "sni",<SSL_ctxID>,<SNI>
AT+QSSLCFG="sni",2,1
# SSL authentication mode
# 0 - No authentication
# 1 - Manage server authentication
# 2 - Manage server and client authentication if requested by the remote server
# +QSSLCFG: "seclevel",<SSL_ctxID>,<seclevel>
AT+QSSLCFG="seclevel",2,2
# SSL authentication version
# 0 - SSL3.0
# 1 - TLS1.0
# 2 - TLS1.1
# 3 - TLS1.2
# 4 - All
# +QSSLCFG: "sslversion",<SSL_ctxID>,<SSL_version>
AT+QSSLCFG="sslversion",2,3
# Supported SSL Cipher Suites. HiveMQ default cipher suites supported https://www.hivemq.com/docs/hivemq/4.12/user-guide/security.html#cipher-suites
# 0X0035 - TLS_RSA_WITH_AES_256_CBC_SHA
# 0X002F - TLS_RSA_WITH_AES_128_CBC_SHA
# 0X0005 - TLS_RSA_WITH_RC4_128_SHA
# 0X0004 - TLS_RSA_WITH_RC4_128_MD5
# 0X000A - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# 0X003D - TLS_RSA_WITH_AES_256_CBC_SHA256
# 0XC011 - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# 0XC012 - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
# 0XC013 - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
# 0XC014 - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
# 0XC027 - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
# 0XC028 - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
# 0XC02F - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
# 0XFFFF - Support all cipher suites above
# +QSSLCFG: "ciphersuite",<SSL_ctxID>,<cipher_suites>
AT+QSSLCFG="ciphersuite",2,0xFFFF
# Ignore the time of authentication
# +QSSLCFG: "ignorelocaltime",<SSL_ctxID>,<ignore_ltime>
AT+QSSLCFG="ignorelocaltime",2,1
# Start MQTT SSL connection
# +QMTOPEN: <client_idx>,<host_name>,<port>
# <client_idx> MQTT socket identifier. Range: 0-5
AT+QMTOPEN=0,"9d52b5d026654fc4b6057be2b55bc5f1.s2.eu.hivemq.cloud",8883
# Connect to MQTT server
# +QMTCONN: <client_idx>,<clientID>,<username>,<password>
# <client_idx> MQTT socket identifier. Range: 0-5
AT+QMTCONN=0,"BG96_UART","Johny","johny123"
Best regards,
Diego from HiveMQ Team