BGS2 AT^SBNW=is_cert,1 command fails - Cinterion Transport Layer Security for Client TCP/IP Services documentation not detailed enough | Telit Cinterion IoT Developer Community
September 24, 2014 - 6:43pm, 17159 views
I am involved in developing a tracking system using Cinterion BGS2 M2M modems and I am having problems loading TLS certificates using the Java tools provided and it has also failed when using the AT^SBNW=is_cert,1 command.
I get the following error;
AT^SBNW=is_cert,1 CONNECT
SECURE CMD READY: SEND COMMAND ...
SECURE CMD TOO MANY DATA ERROR
OK
I am having problems understanding the details of the AT^SBNW=is_cert,1 command in the TLS documentation :-
Transport Layer Security for Client
TCP/IP Services
Application Note 62
Version: 04
DocId: wm01_wm02_an62_tls_v04
This document describes the formats but is not specific about message lengths – are they word counts or byte counts?
It would also be useful for it to show an example HEX dump of a valid certificate AT^SBNW=is_cert,1 upload message.
If anybody knows the answer to these questions please let me know - Jeff White jeffrey.white@projectirongate.co.uk
Great news! I managed to find a 32bit windows 7 machine, I ran:
jdk-6u45-windows-i586.exe
com0com-3.0.0.0-i386-and-x64-signed.zip
termite-3.4.exe
And I copied the rxtxserial.dll that comes in the wm02_tls_tools\cmd_ipcertmgr\win-x86 directory into all the java bin directories.
I sent OK with termite before running cmd_IpCertMgr.jar. Again, the script stopped inside cmd_IpCertMgr.jar without outputting anything, but this time, whilst waiting, i changed the flow control in termite to RTS/CTS, and AT^SBNW=is_cert comes out.
I can repeat this. It seems like you have to set termite with no flow control, send an OK, run cmd_IpCertMgr.jar, then change the flow control in termite to RTS/CTS, then AT and AT^SBNW=is_cert come out.
Trying this back on the windows 10 64 bit machine, the following works:
Java version jdk-6u45-windows-i586.exe from http://www.oracle.com/technetwork/java/javase/downloads/java-archive-dow...
Then copy the wm02_tls_tools\cmd_ipcertmgr\win-x86\rxtxserial.dll to
C:\Program Files (x86)\Java\jdk1.6.0_45\bin and C:\Program Files (x86)\Java\jre6\bin although only one of these might be necessary.
I didn't run the environment variable/path commands, just called the jar using:
"C:\Program Files (x86)\Java\jdk1.6.0_45\bin\java.exe" -verbose -jar cmd_ipcertmgr\win-x86\cmd_IpCertMgr.jar
The important thing seems to be just to open termite with CTS/RTS flow control, and send the OK before starting cmd_IpCertMgr.jar.
Files attached (zip file renamed to .txt so I could attach it).
wm02_tls_tools.txt
Here's an upload of the output decoded into the fields of the commands in AN62:
decoded script output.txt
Hi Bartłomiej,
I'm trying to understand exactly which parts need to have the SHA-1 calculated.
I want to check I can make the **** once I change the certificates, but with an online calculator, https://quick****.com/, I just can't get the same **** as in the tool output.
The tool output:
b9 05 01 00 05 00 06 00 01 00 00 00 69 02 02 00 30 82 02 61 30 82 01 ca a0 03 02 01 02 02 04 5a bc c5 81 30 0d 06 09 2a 86 48 86 f7 0d 01 01 05 05 00 30 75 31 0b 30 09 06 03 55 04 06 13 02 49 4c 31 14 30 12 06 03 55 04 08 13 0b 52 6f 73 68 20 48 61 41 79 69 6e 31 12 30 10 06 03 55 04 07 13 09 50 61 72 6b 20 41 66 65 6b 31 12 30 10 06 03 55 04 0a 13 09 54 72 61 66 66 69 6c 6f 67 31 11 30 0f 06 03 55 04 0b 13 08 48 61 72 64 77 61 72 65 31 15 30 13 06 03 55 04 03 13 0c 45 64 20 47 6f 6c 64 73 74 65 69 6e 30 1e 17 0d 31 38 30 33 32 39 31 30 35 32 34 39 5a 17 0d 31 38 30 36 32 37 31 30 35 32 34 39 5a 30 75 31 0b 30 09 06 03 55 04 06 13 02 49 4c 31 14 30 12 06 03 55 04 08 13 0b 52 6f 73 68 20 48 61 41 79 69 6e 31 12 30 10 06 03 55 04 07 13 09 50 61 72 6b 20 41 66 65 6b 31 12 30 10 06 03 55 04 0a 13 09 54 72 61 66 66 69 6c 6f 67 31 11 30 0f 06 03 55 04 0b 13 08 48 61 72 64 77 61 72 65 31 15 30 13 06 03 55 04 03 13 0c 45 64 20 47 6f 6c 64 73 74 65 69 6e 30 81 9f 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 89 02 81 81 00 cf 8f d1 fd ff 7c 8a 0a b5 8c 32 3c a8 7b 19 0b 97 a2 01 52 e9 98 e3 a3 db ed 26 ac 56 6b ae 6a 3a c3 5d e0 bd 93 ee f5 fd c5 3a 84 fa 4d 4c 99 1d c5 93 da ef eb 50 7a 9f c0 a8 6a fc cf 79 33 46 c1 2e 87 d7 1c 37 b2 6b 2e 5f c6 f9 be 5e 01 36 b4 b5 2f 11 f2 fd ed 47 45 25 db 0b d7 12 25 45 da db 9f a5 5d c5 d9 69 fe 06 15 6c 0e 23 38 68 18 75 0b d8 b0 34 33 58 2b 4b cd 8f 09 db 3b 02 03 01 00 01 30 0d 06 09 2a 86 48 86 f7 0d 01 01 05 05 00 03 81 81 00 b2 8c 00 f1 64 03 4c 29 1d 56 44 73 71 b0 44 c0 f7 7b 51 7f 8e 9c 71 3f 6f 67 8a af 97 a9 03 58 a4 a6 4b 14 ca 81 a7 f3 50 55 14 95 5a 07 db 7a 5e 93 12 4f b0 c1 6b ea b6 37 1f d9 d4 81 4a e2 d0 a4 be cb f0 ed b2 d2 e3 a0 0e b5 ee f1 e2 37 b7 a0 b3 7e e4 7f 6b c3 05 c3 81 8d d0 36 15 5a de 89 28 3b 1a 96 7a 15 34 29 71 96 d6 5f fc a2 0a 41 c4 17 84 38 91 a6 87 d2 3d 29 8f 58 69 b0 7f 02 05 00 30 82 02 77 02 01 00 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 04 82 02 61 30 82 02 5d 02 01 00 02 81 81 00 cf 8f d1 fd ff 7c 8a 0a b5 8c 32 3c a8 7b 19 0b 97 a2 01 52 e9 98 e3 a3 db ed 26 ac 56 6b ae 6a 3a c3 5d e0 bd 93 ee f5 fd c5 3a 84 fa 4d 4c 99 1d c5 93 da ef eb 50 7a 9f c0 a8 6a fc cf 79 33 46 c1 2e 87 d7 1c 37 b2 6b 2e 5f c6 f9 be 5e 01 36 b4 b5 2f 11 f2 fd ed 47 45 25 db 0b d7 12 25 45 da db 9f a5 5d c5 d9 69 fe 06 15 6c 0e 23 38 68 18 75 0b d8 b0 34 33 58 2b 4b cd 8f 09 db 3b 02 03 01 00 01 02 81 80 5a 6e 15 96 6d 1e 4c 62 38 10 b9 be 75 c5 13 f7 59 fc 0a 49 9e 5e af 27 2f e5 55 c9 15 e9 da 56 8b fd 9c 44 13 34 85 93 05 1a 4d d1 ab df cb b4 96 25 03 b3 0a 7e 62 54 da 8f 2c 91 58 4d e8 46 66 e2 c7 16 db 9c 0c ff 5a 4c 7f 41 7d 1b 20 40 d4 ee a4 ed 28 27 e2 d0 4d 5b 45 d4 0f ba dc 2e 62 a5 63 39 c4 b3 1e e3 67 14 cd d9 28 cb b4 19 da e2 54 39 e5 96 ca 31 4a 00 51 55 62 89 82 11 02 41 00 ed d1 dd 76 93 09 ef 56 d4 b3 54 f0 83 5b eb 67 de d6 ae 06 00 0f 3d 31 48 f0 f8 70 44 c6 01 9a 72 5a 7c 3b 88 35 fd 6a a3 61 da dd cc ce d4 46 1b 93 c0 e6 3c 94 00 d1 91 2b 6f ed 3d d2 7c 63 02 41 00 df 6d ce 60 61 f6 d2 f0 31 69 24 43 cc 02 e0 ce 89 1a 65 56 bb 5c 4a 04 48 76 33 6e 1d e8 f1 8b 9d e1 0f 8e ef 65 21 69 d6 00 9f 40 b5 24 99 a9 8c f8 c3 c7 fd a2 40 05 e2 a2 b1 43 b8 d8 01 49 02 41 00 85 fb 68 23 77 6f 6f 71 a1 df 6e 89 19 d8 5d 65 65 7b d9 0a f4 59 a1 85 f4 ac 1d ab 52 73 a3 4f 9a 01 34 60 6d ba cd 0c 99 03 76 44 e3 2f db 13 ac 51 af a9 86 93 73 6a 9d b8 b5 14 19 72 4e 35 02 40 62 78 ae c0 63 ec b8 c3 0b c3 df 2b d2 3a 62 82 24 82 f1 ae ec 1c 9c b2 8e 8d 29 d5 9a 71 14 24 08 8d 2c a2 3e 78 3f e5 b9 5f c4 d0 6c 05 99 83 d4 91 bf 17 e1 7d 24 e2 73 24 69 24 03 cf 8f a1 02 41 00 81 6d d7 92 a8 56 58 58 d3 18 a0 54 62 aa 55 5f 40 8a a9 5e db a0 c0 eb c3 18 70 50 39 4b 0c d1 7c 2b e0 f0 81 26 6d 76 cf 73 65 f8 13 8c ad b0 0d d7 2d 1f cf ab ee bd f0 27 43 77 ae 53 d6 74 14 00 04 00 30 39 39 39 39 39 30 30 31 32 33 34 35 36 31 00 b1 00 03 00 6b 4c 4c 65 79 6f 61 4a 30 5a 6a 4c 4a 30 79 2b 51 62 64 47 31 47 49 67 57 58 70 6d 34 38 38 55 43 78 47 4b 31 6f 2b 62 6d 65 4d 31 4f 36 36 44 57 6c 33 44 59 4c 34 62 70 38 64 6f 6d 37 56 4f 52 77 31 4f 52 62 6f 6d 47 57 4a 49 68 68 78 48 53 39 70 68 55 45 7a 50 4c 6a 52 31 77 5a 63 74 49 46 41 7a 53 67 78 2b 36 30 69 48 59 75 42 6f 62 55 75 62 41 55 69 56 32 44 4d 4b 45 64 77 78 49 4b 78 75 48 78 46 49 70 53 62 67 70 43 45 74 45 62 4d 4d 4b 4e 71 36 69 4a 5a 57 4c 48 43 42 4e 70 53 4d 44 44 2b 5a 38 50 63 3d 00
My understanding from AN62 was that it starts from after the first two bytes which are the length, and goes until the end of the IMEI number.
I can't seem to find a calculator which gives the same **** as the one in this output. More to the point, why is it so long here, I thought it should be 28 characters.
With this ****ing that includes the IMEI, there's no way to use the same serial string to load multiple modems, is there? Even if the actual certificate is the same?
Hello,
The PC I have tested with has also 64bit Win 10 OS. I didn't need to do anything special with RXTX. I just opened the command window as administrator, executed the script to configure Java environment for the session (I have used 32bit Java 7) and then run cmd_IpCertMgr.jar with appropriate parameters. In my case it worked without any tricks.
In your case you are using some additional software to sniff the communication between the module and cmd_IpCertMgr.jar application probably. Maybe this also is causing the problems in communication.
Generally I think that these Java tools were prepared to simplify the process and it still is a good idea to use them. It is unfortunately true that you need to use IMEI to send the certificate so in fact you need to generate separate command for each module. But you don't need to generate separate certificate at least.
As using the Java tools is the recommended way it seems that this secure command syntax is not very widely documented. You may decompile cmd_IpCertMgr.jar to find more information about the possible implementation. I did so and found the following method:
private String getSignature(byte[] buffer)
throws KeyStoreException, InvalidKeyException, NoSuchPaddingException, BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, UnrecoverableKeyException
{
Key pk = this.keystore.getKey(this.alias, this.keypass);
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
byte[] digest = sha1.digest(buffer);
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(1, (PrivateKey)pk);
byte[] cipherText = cipher.doFinal(digest);
return Base64.encode(cipherText);
}
}
It looks like the SHA1 signature is encrypted with RSA before being converted to base64 format. However RSA encryption was not mentioned in the document.
Best regards,
Bartłomiej
Hi Everyone,
Here's a document describing the data format and how to record the tool output. I will need to add the exact details of the message signature algorithm.
Ed.