SwitchEV / RISE-V2G

The only fully-featured reference implementation of the Vehicle-2-Grid communication interface ISO 15118
MIT License
220 stars 92 forks source link

Invalid EXI when receiving one message in multiple TLS records. #85

Open jpo-stx opened 2 years ago

jpo-stx commented 2 years ago

I am currently using RiseV2G EV with our own EVSE. When sending data with maximum TLS record size of i.e. 3kb and the message is therefore split up in two records, the application reads only the first record and shows the rest of the EXI data as zeros:

2022-01-13T10:33:53,208 DEBUG [Thread-1] TLSClient: Message sent
2022-01-13T10:33:53,208 DEBUG [Thread-1] V2GCommunicationSessionEVCC: New state is WaitForCertificateInstallationRes
2022-01-13T10:33:53,881 DEBUG [Thread-1] TLSClient: Length of V2GTP payload in bytes according to V2GTP header: 4252
2022-01-13T10:33:53,882 DEBUG [Thread-1] TLSClient: Message received
2022-01-13T10:33:53,882 DEBUG [Thread-1] EXIficientCodec: Received EXI stream: 8098020B6D0B10D2CDFC5C4A895A1D1D1C0E8BCBDDDDDDCB9DCCCB9BDC99CBD5148BD8D85B9BDB9A58D85B0B595E1A4BD0D5A1D1D1C0E8BCBDDDDDDCB9DCCCB9BDC99CBCC8C0C0C4BCC0D0BDE1B5B191CDA59CB5B5BDC9948D958D91CD84B5CDA184C8D4D910311B4B219012B43A3A381D1797BBBBBB973B999737B93397AA2917B1B0B737B734B1B0B616B2BC3497A429687474703A2F2F7777772E77332E6F72672F323030312F30342F786D6C656E6323736861323536420B4FF9BB803878F3BB82A16B7508900A0FD67943BAC8DDB1355CDFB76D083E12F040C46D2C86204AD0E8E8E0745E5EEEEEEE5CEE665CDEE4CE5EA8A45EC6C2DCDEDCD2C6C2D85ACAF0D25E90A5A1D1D1C0E8BCBDDDDDDCB9DCCCB9BDC99CBCC8C0C0C4BCC0D0BDE1B5B195B98C8DCDA184C8D4D908121B6407CA9BBD25C144ED4D255C7841181A37907FCC4868742161699F9955BD010311B4B21A012B43A3A381D1797BBBBBB973B999737B93397AA2917B1B0B737B734B1B0B616B2BC3497A429687474703A2F2F7777772E77332E6F72672F323030312F30342F786D6C656E6323736861323536420DD2EDA401D6D190B71182FAE0996258ADCCB3EC539CD7554F3AC631AB61E9A0C040C46D2C86604AD0E8E8E0745E5EEEEEEE5CEE665CDEE4CE5EA8A45EC6C2DCDEDCD2C6C2D85ACAF0D25E90A5A1D1D1C0E8BCBDDDDDDCB9DCCCB9BDC99CBCC8C0C0C4BCC0D0BDE1B5B195B98C8DCDA184C8D4D9083CC95EE6E24A59EA1A0EEDAA66BE5343C27A2568BB80126E5CDAA19A7B80EBF4C4A06484BD87E8950733237EB265A3FFF01E2359212A7D8D6867CAB181452BCD9C3DACC00045FC97B123708150B93644A6163EC361B8EE7DFCBAEA60A6566C66A4C4206002BB0430820237308201DCA003020102020819B94197210BA4A1300A06082A8648CE3D0403023073310B30090603550406130244453111300F06035504070C0848616E6E6F76657231173015060355040A0C0E536576656E7374617820476D624831143012060355040B0C0B446576656C6F706D656E743122302006035504030C195354582044656D6F20504B492043504F205375622043412032301E170D3232303130353134343531315A170D3232303530363134343531315A3073310B30090603550406130244453111300F06035504070C0848616E6E6F76657231173015060355040A0C0E536576656E7374617820476D624831143012060355040B0C0B446576656C6F706D656E74310D300B06035504030C044350494431133011060A0992268993F22C640119160343504F3059301306072A8648CE3D020106082A8648CE3D03010703420004CC29D4D4ED4EEB8039F262564E317AABDFE6C491AB831B6CA730E6D890A4FDBC619973DBEF613715CE142D977A3ACD8AF8FD7CF66F33EE9A9C780C3965C3A87FA35A305830090603551D1304023000300B0603551D0F040403020490301D0603551D0E04160414584E6BB0A0E0BF3023AC1B18FF0414A38B942088301F0603551D2304183016801467E7B87ADBAA47588BDBB23F5C02F6DB265AB845300A06082A8648CE3D0403020349003046022100DF14B14BFADD199DADA4C6C047114EC9017709E715F77D1C2AD653DC0127A865022100D7E0FCE0AE9560EB161A0E62AF415C2A98AAC0FD9F2B982CD973D3841E77BC3206A8218410128984100FB50018100810104807CE4D521339C4F1998050304154324671E8201811840C2188598048301AA820309812222988898078301AA820386042430B73737BB32B9188B980A8301AA8205060729B2BB32B739BA30BC1023B6B124188A18090301AA82058605A232BB32B637B836B2B73A188F180E0301AA8201860AA9AA2C102232B6B7902825A4902B1923902937B7BA18899808830504C91344C9F91632008C8B01AB1923980F0B8699191818981A989A1A1A98982D0B86991B1818981A189A1A1A98982D183A188598048301AA820309812222988898078301AA820386042430B73737BB32B9188B980A8301AA8205060729B2BB32B739BA30BC1023B6B124188A18090301AA82058605A232BB32B637B836B2B73A189198108301AA8201860D29AA2C102232B6B7902825A490283937BB1029BAB11021A09018982C98098303954324671E81008304154324671E81808381A1000258569D3D79CB1839D89AC6486F29CA80E800F9866E117D6996CDC42B3BDDD5282D251B4B5D79A251ADA6ED339DCF2EC45D1D1A4B120D434A54D8508A1786ED35D1B0182F18078301AA8E89820418030080FF81008098058301AA8E8782020181008B180E8301AA8E87020B020A27C9AE316FC69C8F0B506100F49842ED9C70DC55980F8301AA8E91820C180B400A5FECCD3CA4278E1FC11463238F8BA9C4CB0DC58818050304154324671E82018101A4801823011080402328CD1D05F3792F4F6556FF99BC9422A744F68FD0592788FCA728F691B73D81108074FB1E2ECA4DC9BA7C7FC35B18870400DC57C13707EE11DCA5074DC454A8DA010620218410120184100F2D00181008101048064F09628D850E40298050304154324671E820181183A188598048301AA820309812222988898078301AA820386042430B73737BB32B9188B980A8301AA8205060729B2BB32B739BA30BC1023B6B124188A18090301AA82058605A232BB32B637B836B2B73A189198108301AA8201860D29AA2C102232B6B7902825A490283937BB1029BAB11021A09018980F0B8699191818981A989A1A1A9898AD0B86991A1818981A989A1A1A9898AD183A188598048301AA820309812222988898078301AA820386042430B73737BB32B9188B980A8301AA8205060729B2BB32B739BA30BC1023B6B124188A18090301AA82058605A232BB32B637B836B2B73A189198108301AA8201860D29AA2C102232B6B7902825A490283937BB1029BAB11021A09019182C98098303954324671E81008304154324671E81808381A10002247DB9834CB9AB58FC62C5F0BC3B776C406981166A413BD6191D4F30E6A0D1E7C17470B0C56CFFD2F6BBD6DBB71C416FF8502FEDF133B8019B477043A35A8BA0D1B0182F18078301AA8E89820418030080FF81008018058301AA8E8782020181008B180E8301AA8E87020B020A017CC342837A06F59C64E05B48EB7838081DF981980F8301AA8E91820C180B400A27C9AE316FC69C8F0B506100F49842ED9C70DC5598050304154324671E82018101A48018230110806B5D99F3F18C00B5AED12ABBA023F5D0A145CC16F3B4B40CE05F82E302210C9801108067440FE529915AFF61BA3EA01F87F1619F83B92434DC7ADC7BD5F37E7A275B78900569643129C10C208088CC2080722800C080408082403132A687E785A8CA0C0281820AA192338F4100C08C1C8C42CC024180D5410184C091114C444C03C180D54101C30212185B9B9BDD995C8C45CC054180D54102830394D95D995B9CDD185E0811DB58920C450C048180D54102C302D1195D995B1BDC1B595B9D0C484C07C180D54100C30614D5160811195B5BC81412D2481353C814DD588810D0480C8C0785C34C8C8C0C4C4CCC0E0D4C8CCCD685C34C8D0C0C4C4CCC0E0D4C8CCCD68C17CC42CC024180D5410184C091114C444C03C180D54101C30212185B9B9BDD995C8C45CC054180D54102830394D95D995B9CDD185E0811DB58920C450C048180D54102C302D1195D995B1BDC1B595B9D0C438C030180D54100C30151535052510C164C04C181CAA192338F408041820AA192338F40C041C0D080010E0BD949C3212DA2DEB369134408E7FCB517A6CC16F1B186E5BBA3D2F12D3759A9252D1EBA17FC0ECED47F6714243CEE1552E26CA8EB82D8E81252E35789003328D68C160C024180D54744C1008C000C02C180D54743C10100C080FE0C074180D54743810581052018F455BDB9450C7D7647934A4B6FB9A544240C8C07C180D54748C1060C05A0051C208BF4FDC7DA5EE86E9E428B0F17649BE771CC8C0281820AA192338F4100C080D2400C1180884031D43CFC036038DC3C4011C4ADBF8FA8432BBDF7899B70213976E48A644FE3A440884038F8BC65609F2A3B115B76EC274A8790AD57D02C211E0FD7DFFA0E59A15C17C0017E0861040476610403C3400604020404101D0AD25D9436822260140C10550C919C7A08060460E262166000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
ERROR:  ''
2022-01-13T10:33:53,889 ERROR [Thread-1] EXIficientCodec: Error occurred while trying to decode (TransformerException)
javax.xml.transform.TransformerException: java.lang.NullPointerException

The application should wait for more data when it hasn't received the amount of data specified in the V2GTP header:

https://github.com/SwitchEV/RISE-V2G/blob/9abd5ae7298c969dc921238dd52b10fcb8ac26ba/RISE-V2G-EVCC/src/main/java/com/v2gclarity/risev2g/evcc/transportLayer/StatefulTransportLayerClient.java#L110

dportnrj commented 2 years ago

How did you get maximum TLS record size 3kb? (The allowed values for this field are: 2^9, 2^10, 2^11, and 2^12 https://www.rfc-editor.org/rfc/rfc6066)

jpo-stx commented 2 years ago

Hi, it seems that the configuration on my side is not correct then.

But even if I would set it to the option 2^12=4096, I think that I would have the same outcome, since the EXI is of size 4252 which exceeds the maximum record size.

dportnrj commented 2 years ago

Maximum TLS record size is 2^14:

TLS specifies a fixed maximum plaintext fragment length of 2^14 bytes. https://www.rfc-editor.org/rfc/rfc6066