Skip to content

Commit fb746cf

Browse files
blakeyjasonblakeyjason
authored andcommitted
Revert "Fixed problem with demo disconnecting from Solace, updated URL -> FQDN, and updated default port to ttyUSB2"
This reverts commit 4e0c292.
1 parent ad34b4a commit fb746cf

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

golang/src/tlsdemo/cmd/cmd_handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func hdlDemo( Parameters []string, pConfig *Config_t ) error {
5656
opts.SetClientID("IoT-Device")
5757
opts.SetTLSConfig( pTlsConfig )
5858
opts.SetProtocolVersion( uint(4) ) // MQTT 3.1.1
59-
opts.SetAutoReconnect( true )
6059

6160
// Attempting to connect to the server for a number of times before asserting
6261
// that the connection failed

golang/src/tlsdemo/cmd/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (priv *IoTPrivateKey_t) Sign(rand io.Reader, digest []byte, opts crypto.Sig
276276
// We decode the response from the command
277277
SignatureStr, err := ParseResponse( string(CommandOutput), PY_SIGNATURE_LABEL )
278278
if err != nil {
279-
return nil, fmt.Errorf("Couldn't parse the FQDN: %s", err.Error())
279+
return nil, fmt.Errorf("Couldn't parse the URL: %s", err.Error())
280280
}
281281

282282
// The signature is returned as a base64 encoded string

golang/src/tlsdemo/cmd/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var PY_MW_USB_PORT string
3434
const BUILD_DIR = "BUILD_DIR" // Environment variable set by setenv.sh to reach Python functions
3535
const PY_RELATIVE_PATH = "python/iot_mw.py"
3636
const PY_PUBKEY_LABEL = "PublicKey"
37-
const PY_URL_LABEL = "FQDN"
37+
const PY_URL_LABEL = "URL"
3838
const PY_PORT_LABEL = "Port"
3939
const PY_SIGNATURE_LABEL = "Signature"
4040
const PY_CLIENT_CERT_LABEL = "ClientCert"

python/demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ def print_status(self):
104104
utils.getRandom, \
105105
16 ) )
106106

107-
# We test the 'getFqdnAndPort' function
107+
# We test the 'getUrlAndPort' function
108108
TestArray.append( TestCase( \
109-
"Testing 'getFqdnAndPort'", \
110-
utils.getFqdnAndPort ) )
109+
"Testing 'getUrlAndPort'", \
110+
utils.getUrlAndPort ) )
111111

112112
# We test the 'generateSignature', 'getCertificate' and
113113
# 'verifySignature' functions at the same time. First, we

python/iot_mw.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
signCmd.add_argument('--tbs', action='store', type=str, dest='tbs', required=True, help="Base64 encoded string of data to be signed")
4545
signCmd.add_argument('--raw', action='store_true', dest='raw', default=False, help="If true, performs a raw signature (no hash)")
4646

47-
# getFqdnAndPortCmd
48-
getFqdnAndPort = subparsers.add_parser('getFqdnAndPort', help='Retrieves the URL and the port of the server endpoint')
47+
# getUrlAndPortCmd
48+
getUrlAndPort = subparsers.add_parser('getUrlAndPort', help='Retrieves the URL and the port of the server endpoint')
4949

5050
# getAllInfo
5151
getAllInfo = subparsers.add_parser('getAllInfo', help='Retrieves all the information required for establishing a TLS session and validates the cryptographic material provided by the SIM card')
@@ -96,12 +96,12 @@ def getAllInfoCmd():
9696
aspCert = utils.getCertificate( utils.ASP_CERTIFICATE_ID )
9797
endpointSignature = base64.b64encode( utils.readAsn1File( utils.SERVER_ENDPOINT_HASH_ID ) )
9898
aspCertSignature = base64.b64encode( utils.readAsn1File( utils.SERVER_CERT_HASH_ID ) )
99-
URL, Port = utils.getFqdnAndPort( IsSecure=True ) # Check 2
99+
URL, Port = utils.getUrlAndPort( IsSecure=True ) # Check 2
100100

101101
# Then we start making some verifications:
102102
# 1 - Validate that the rootCert is self-signed and that it signs the subCert and that
103103
# the subCert signs the client cert.
104-
# 2 - Validate that the signature on the endpoint (Already done in getFqdnAndPort)
104+
# 2 - Validate that the signature on the endpoint (Already done in getUrlAndPort)
105105
# 3 - Validate that the ASP certificate was signed by the subCert
106106
# 4 - Ensure that the client certificate is contained in the DNS's database
107107

@@ -140,7 +140,7 @@ def getAllInfoCmd():
140140

141141
# Once all the checks have been successfully completed, we return the information
142142
print("", flush=True)
143-
print("FQDN: " + URL )
143+
print("URL: " + URL )
144144
print("Port: " + str(Port))
145145
print("ClientCert: " + clientCert.decode("utf-8").replace("\n",""))
146146
print("AspCert: " + aspCert.decode("utf-8").replace("\n",""))
@@ -165,11 +165,11 @@ def getAllInfoCmd():
165165
print("", flush=True)
166166
print("PublicKey: " + utils.extractPubKeyFromCert(ClientCertificate).decode("utf-8").replace("\n",""))
167167

168-
elif args.command == "getFqdnAndPort":
168+
elif args.command == "getUrlAndPort":
169169
utils.init()
170-
URL, Port = utils.getFqdnAndPort()
170+
URL, Port = utils.getUrlAndPort()
171171
print("", flush=True)
172-
print("FQDN: " + URL)
172+
print("URL: " + URL)
173173
print("Port: " + str(Port))
174174

175175
elif args.command == "isProvisioned":

python/utils.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# - getRandom
2121
# - readAsn1File
2222
# - getCertificate
23-
# - getFqdnAndPort
24-
# - verifyFqdnAndPort
23+
# - getUrlAndPort
24+
# - verifyUrlAndPort
2525
# - generateSignature
2626
# - generateRawSignature
2727
# - init
@@ -104,7 +104,7 @@
104104

105105
# This part is used to configure the port that will be used to communicate with
106106
# the modem. You can modify this string based on your connection with the modem.
107-
MODEM_PORT = "/dev/ttyUSB2"
107+
MODEM_PORT = "/dev/ttyUSB0"
108108

109109
# This is just for esthetic purposes and defines how many PEM characters wide a
110110
# certificate will be.
@@ -124,7 +124,7 @@
124124
# EPHEMERAL_PUBLIC_KEY_ID = 5 -> Needs to be generated (not planning on implementing that yet)
125125
ROOT_CERTIFICATE_ID = 6
126126
CIRA_SUB_CERTIFICATE_ID = 7
127-
SERVER_ENDPOINT_ID = 8 # Retrieved with the function "getFqdnAndPort"
127+
SERVER_ENDPOINT_ID = 8 # Retrieved with the function "getUrlAndPort"
128128
SERVER_ENDPOINT_HASH_ID = 9
129129
SERVER_CERT_HASH_ID = 10
130130

@@ -689,7 +689,7 @@ def getCertificate( ContainerId ):
689689
# @return URL string
690690
# @return Port string
691691
#******************************************************************************#
692-
def getFqdnAndPort( IsSecure=True ):
692+
def getUrlAndPort( IsSecure=True ):
693693

694694
# We prepare the values for retrieving the certificate
695695
uJsonStrArray = ( ctypes.c_uint8 * MAX_SIZE_URL_PORT )()
@@ -714,20 +714,17 @@ def getFqdnAndPort( IsSecure=True ):
714714

715715
# We check to see if we can verify the signature of the endpoint.
716716
if IsSecure:
717-
if not verifyFqdnAndPort( jsonString ):
718-
raise Exception("Invalid FQDN and port number")
717+
if not verifyUrlAndPort( jsonString ):
718+
raise Exception("Invalid URL and port number")
719719
elif CPP_LOG_LEVEL <= LOG_LEVEL_NOTICE:
720720
# Note that we could make this logging better at the Python level
721-
log( LOG_LEVEL_NOTICE, "The signature on the FQDN and port number is valid")
721+
log( LOG_LEVEL_NOTICE, "The signature on the URL and port number is valid")
722722

723723
# We transform the string into a JSON object
724724
jsonObject = json.loads( jsonString )
725725
URL = jsonObject[URL_LABEL]
726726
Port = jsonObject[PORT_LABEL]
727727

728-
print("GOT FQDN: " + URL);
729-
print("GOT PORT: " + str(Port));
730-
731728
return URL, Port
732729

733730
#******************************************************************************#
@@ -739,7 +736,7 @@ def getFqdnAndPort( IsSecure=True ):
739736
# @return URL string
740737
# @return Port string
741738
#******************************************************************************#
742-
def verifyFqdnAndPort( UrlAndPort ):
739+
def verifyUrlAndPort( UrlAndPort ):
743740

744741
# We retrieve the signature and the certificate stored on the SIM card
745742
endpointSignature = base64.b64encode( readAsn1File( SERVER_ENDPOINT_HASH_ID ) )

run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SCRIPTDIR="$( cd "$(dirname "$0")" ; pwd -P )"
44

5-
PORT="/dev/ttyUSB2"
5+
PORT="/dev/ttyUSB0"
66

77
if [[ -z "${BUILD_DIR}" ]]; then
88
source "${SCRIPTDIR}/setenv.sh"

0 commit comments

Comments
 (0)