SwitchEV / RISE-V2G

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

Make sure moSubCA2.pkcs8.der is added to SECC archives #8

Closed lategoodbye closed 7 years ago

lategoodbye commented 7 years ago

Make sure MO Sub-CA 2 PKCS#8 file is added to package, because it's required by SECC dummy backend

MarcMueltin commented 7 years ago

Interesting. I don't remember creating or editing the file RISE-V2G-SECC/src/assembly/bin.xml in the first place. Is that automatically created by Maven?

Can you please elaborate why exactly you need this? Is this a problem on embedded devices otherwise? Because I never encountered a problem regarding this issue before.

lategoodbye commented 7 years ago

Sorry, i'm not a Maven expert. But this bin.xml is responsible for building the archive files like target/secc-1.0.0-snapshot.zip. This zip file usualy contains all necessary files (jar, keystore , truststore, certs), but with the new release the backend uses moSubCA2.pkcs8.der during contract handling. Without the der file a exception is raised during charging (payment = contract). I'm out of office, so i can't provide a log for now.

MarcMueltin commented 7 years ago

Before the moSubCA2.pkcs8.der was used, the moSubCA2.key was applied. But this .key file was also not referenced in the bin.xml file. Did you experience the same trouble before as well? The only difference is now that instead of a PEM encoded private key, we need a DER encoded private key. That's why I changed the file ending to .der.

lategoodbye commented 7 years ago

Here is the output on SECC side in case moSubCA2.pkcs8.der isn't available:

*******************************************
* New V2G communication session initialized
*******************************************
2017-08-07T08:21:02,595 DEBUG [TLSServerThread] TLSServer: Waiting for new TLS client connection ...
2017-08-07T08:21:02,767 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:02,798 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForSupportedAppProtocolReq: SupportedAppProtocolReq received
2017-08-07T08:21:02,798 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForSupportedAppProtocolReq: Preparing to send SupportedAppProtocolRes
2017-08-07T08:21:02,798 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:02,798 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForSessionSetupReq
2017-08-07T08:21:02,877 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:02,892 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForSessionSetupReq: SessionSetupReq received
2017-08-07T08:21:02,908 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForSessionSetupReq: Preparing to send SessionSetupRes
2017-08-07T08:21:02,908 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:02,908 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForServiceDiscoveryReq
2017-08-07T08:21:02,970 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:02,970 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForServiceDiscoveryReq: ServiceDiscoveryReq received
2017-08-07T08:21:03,017 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForServiceDiscoveryReq: Preparing to send ServiceDiscoveryRes
2017-08-07T08:21:03,033 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:03,033 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is ForkState
2017-08-07T08:21:03,064 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:03,080 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForPaymentServiceSelectionReq
2017-08-07T08:21:03,080 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForPaymentServiceSelectionReq: PaymentServiceSelectionReq received
2017-08-07T08:21:03,080 INFO  [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForPaymentServiceSelectionReq: Payment option CONTRACT has been chosen by EVCC
2017-08-07T08:21:03,080 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForPaymentServiceSelectionReq: Preparing to send PaymentServiceSelectionRes
2017-08-07T08:21:03,080 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:03,080 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is ForkState
2017-08-07T08:21:03,111 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:03,127 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForPaymentDetailsReq
2017-08-07T08:21:03,127 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForPaymentDetailsReq: PaymentDetailsReq received
2017-08-07T08:21:03,142 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForPaymentDetailsReq: Preparing to send PaymentDetailsRes
2017-08-07T08:21:03,142 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:03,142 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForAuthorizationReq
2017-08-07T08:21:03,173 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:03,173 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForAuthorizationReq: AuthorizationReq received
2017-08-07T08:21:03,173 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] SecurityUtils: Verifying digest for element 'ID1'
2017-08-07T08:21:03,173 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] SecurityUtils: Verifying signature of SignedInfo element ...
2017-08-07T08:21:03,173 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForAuthorizationReq: Preparing to send AuthorizationRes
2017-08-07T08:21:03,189 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:03,189 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForChargeParameterDiscoveryReq
2017-08-07T08:21:03,189 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message received
2017-08-07T08:21:03,189 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForChargeParameterDiscoveryReq: ChargeParameterDiscoveryReq received
2017-08-07T08:21:03,720 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForChargeParameterDiscoveryReq: SAScheduleList has been provided
2017-08-07T08:21:03,720 ERROR [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] SecurityUtils: NoSuchFileException occurred while trying to access private key at location './moSubCA2.pkcs8.der'
2017-08-07T08:21:03,720 ERROR [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] DummyBackendInterface: No private key available from MO Sub-CA 2 PKCS#8 file
2017-08-07T08:21:03,736 ERROR [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] SecurityUtils: InvalidKeyException occurred while trying to create signature
java.security.InvalidKeyException: Key must not be null
        at sun.security.ec.ECKeyFactory.engineTranslateKey(ECKeyFactory.java:134) ~[sunec.jar:1.8.0_151]
        at java.security.KeyFactory.translateKey(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ec.ECKeyFactory.toECKey(ECKeyFactory.java:98) ~[sunec.jar:1.8.0_151]
        at sun.security.ec.ECDSASignature.engineInitSign(ECDSASignature.java:218) ~[sunec.jar:1.8.0_151]
        at sun.security.ec.ECDSASignature.engineInitSign(ECDSASignature.java:211) ~[sunec.jar:1.8.0_151]
        at java.security.Signature$Delegate.engineInitSign(Unknown Source) ~[?:1.8.0_141]
        at java.security.Signature.initSign(Unknown Source) ~[?:1.8.0_141]
        at org.v2gclarity.risev2g.shared.utils.SecurityUtils.signSignedInfoElement(SecurityUtils.java:1684) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.shared.messageHandling.MessageHandler.getHeader(MessageHandler.java:187) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.shared.messageHandling.MessageHandler.getV2GMessage(MessageHandler.java:168) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.shared.messageHandling.MessageHandler.getV2GMessage(MessageHandler.java:155) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.shared.misc.State.getSendMessage(State.java:99) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.shared.misc.State.getSendMessage(State.java:61) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.secc.states.WaitForChargeParameterDiscoveryReq.processIncomingMessage(WaitForChargeParameterDiscoveryReq.java:135) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.secc.session.V2GCommunicationSessionSECC.processIncomingMessage(V2GCommunicationSessionSECC.java:183) [secc-1.0.0-SNAPSHOT.jar:?]
        at org.v2gclarity.risev2g.secc.session.V2GCommunicationSessionSECC.update(V2GCommunicationSessionSECC.java:161) [secc-1.0.0-SNAPSHOT.jar:?]
        at java.util.Observable.notifyObservers(Unknown Source) [?:1.8.0_141]
        at org.v2gclarity.risev2g.secc.transportLayer.ConnectionHandler.run(ConnectionHandler.java:134) [secc-1.0.0-SNAPSHOT.jar:?]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
2017-08-07T08:21:03,736 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] WaitForChargeParameterDiscoveryReq: Preparing to send ChargeParameterDiscoveryRes
2017-08-07T08:21:03,752 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Message sent
2017-08-07T08:21:03,752 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: New state is WaitForPowerDeliveryReq
2017-08-07T08:21:03,814 ERROR [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: IOException occurred
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source) ~[?:1.8.0_141]
        at java.net.SocketInputStream.read(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ssl.InputRecord.readFully(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ssl.InputRecord.read(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source) ~[?:1.8.0_141]
        at sun.security.ssl.AppInputStream.read(Unknown Source) ~[?:1.8.0_141]
        at java.io.InputStream.read(Unknown Source) ~[?:1.8.0_141]
        at org.v2gclarity.risev2g.secc.transportLayer.ConnectionHandler.run(ConnectionHandler.java:103) [secc-1.0.0-SNAPSHOT.jar:?]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
2017-08-07T08:21:03,814 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] ConnectionHandler: Connection to client closed
2017-08-07T08:21:03,814 ERROR [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionSECC: Terminating V2G communication session, reason: ConnectionHandler has notified an error
2017-08-07T08:21:03,814 DEBUG [ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11] V2GCommunicationSessionHandlerSECC: Thread 'ConnectionThread fe80:0:0:0:604f:a613:2eec:ca7f%11' has been interrupted and removed