Merge branch 'hotfix/porsche-test'
This commit is contained in:
commit
c8c9fb21d6
|
@ -20,6 +20,7 @@ import javax.net.ssl.SSLHandshakeException;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import org.eclipse.risev2g.shared.enumerations.GlobalValues;
|
import org.eclipse.risev2g.shared.enumerations.GlobalValues;
|
||||||
|
import org.eclipse.risev2g.shared.misc.TimeRestrictions;
|
||||||
import org.eclipse.risev2g.shared.misc.V2GTPMessage;
|
import org.eclipse.risev2g.shared.misc.V2GTPMessage;
|
||||||
import org.eclipse.risev2g.shared.utils.SecurityUtils;
|
import org.eclipse.risev2g.shared.utils.SecurityUtils;
|
||||||
|
|
||||||
|
@ -78,7 +79,9 @@ public class TLSClient extends StatefulTransportLayerClient {
|
||||||
GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString());
|
GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString());
|
||||||
|
|
||||||
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||||
|
getLogger().debug("Creating socket to TLS server ...");
|
||||||
setTlsSocketToServer((SSLSocket) sslSocketFactory.createSocket(host, port));
|
setTlsSocketToServer((SSLSocket) sslSocketFactory.createSocket(host, port));
|
||||||
|
getLogger().debug("TLS socket to server created");
|
||||||
setInStream(getTlsSocketToServer().getInputStream());
|
setInStream(getTlsSocketToServer().getInputStream());
|
||||||
setOutStream(getTlsSocketToServer().getOutputStream());
|
setOutStream(getTlsSocketToServer().getOutputStream());
|
||||||
|
|
||||||
|
@ -95,7 +98,17 @@ public class TLSClient extends StatefulTransportLayerClient {
|
||||||
String[] enabledProtocols = {"TLSv1.2"};
|
String[] enabledProtocols = {"TLSv1.2"};
|
||||||
getTlsSocketToServer().setEnabledProtocols(enabledProtocols);
|
getTlsSocketToServer().setEnabledProtocols(enabledProtocols);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The communication session setup timeout needs to be set here in case there is any problem with the
|
||||||
|
* TLS handshake.
|
||||||
|
* The timeout value will be overwritten with every new message being sent
|
||||||
|
*/
|
||||||
|
getTlsSocketToServer().setSoTimeout(TimeRestrictions.V2G_EVCC_COMMUNICATION_SETUP_TIMEOUT);
|
||||||
|
|
||||||
|
getLogger().debug("Starting TLS handshake ...");
|
||||||
getTlsSocketToServer().startHandshake();
|
getTlsSocketToServer().startHandshake();
|
||||||
|
getLogger().debug("TLS handshake finished");
|
||||||
|
|
||||||
Certificate[] seccCertificates = getTlsSocketToServer().getSession().getPeerCertificates();
|
Certificate[] seccCertificates = getTlsSocketToServer().getSession().getPeerCertificates();
|
||||||
X509Certificate seccLeafCertificate = (X509Certificate) seccCertificates[0];
|
X509Certificate seccLeafCertificate = (X509Certificate) seccCertificates[0];
|
||||||
|
|
||||||
|
@ -116,6 +129,8 @@ public class TLSClient extends StatefulTransportLayerClient {
|
||||||
getLogger().error("TLS client connection failed (UnknownHostException)!", e);
|
getLogger().error("TLS client connection failed (UnknownHostException)!", e);
|
||||||
} catch (SSLHandshakeException e) {
|
} catch (SSLHandshakeException e) {
|
||||||
getLogger().error("TLS client connection failed (SSLHandshakeException)", e);
|
getLogger().error("TLS client connection failed (SSLHandshakeException)", e);
|
||||||
|
} catch (SocketTimeoutException e) {
|
||||||
|
getLogger().fatal("TLS client connection failed (SocketTimeoutException) due to session setup timeout", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getLogger().error("TLS client connection failed (IOException)!", e);
|
getLogger().error("TLS client connection failed (IOException)!", e);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
|
|
@ -123,42 +123,46 @@ public class V2GCommunicationSessionHandlerSECC implements Observer {
|
||||||
private void processSECCDiscoveryReq(DatagramPacket udpClientPacket) {
|
private void processSECCDiscoveryReq(DatagramPacket udpClientPacket) {
|
||||||
setV2gTpMessage(new V2GTPMessage(udpClientPacket.getData()));
|
setV2gTpMessage(new V2GTPMessage(udpClientPacket.getData()));
|
||||||
|
|
||||||
if (getMessageHandler().isV2GTPMessageValid(getV2gTpMessage()) &&
|
try {
|
||||||
Arrays.equals(getV2gTpMessage().getPayloadType(), GlobalValues.V2GTP_PAYLOAD_TYPE_SDP_REQUEST_MESSAGE.getByteArrayValue())) {
|
if (getMessageHandler().isV2GTPMessageValid(getV2gTpMessage()) &&
|
||||||
|
Arrays.equals(getV2gTpMessage().getPayloadType(), GlobalValues.V2GTP_PAYLOAD_TYPE_SDP_REQUEST_MESSAGE.getByteArrayValue())) {
|
||||||
|
|
||||||
SECCDiscoveryReq seccDiscoveryReq = new SECCDiscoveryReq(getV2gTpMessage().getPayload());
|
SECCDiscoveryReq seccDiscoveryReq = new SECCDiscoveryReq(getV2gTpMessage().getPayload());
|
||||||
setSecurity(seccDiscoveryReq.getSecurity());
|
setSecurity(seccDiscoveryReq.getSecurity());
|
||||||
getLogger().debug("SECCDiscoveryReq received");
|
getLogger().debug("SECCDiscoveryReq received");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The TCP and TLS server ports are created upon initialization of the TCP/TLS server and will
|
* The TCP and TLS server ports are created upon initialization of the TCP/TLS server and will
|
||||||
* remain the same for every connected EV. Only TCP or TLS are allowed as transport
|
* remain the same for every connected EV. Only TCP or TLS are allowed as transport
|
||||||
* protocols for further communication beyond the SECCDiscoveryReq/-Res handshake (not UDP).
|
* protocols for further communication beyond the SECCDiscoveryReq/-Res handshake (not UDP).
|
||||||
*
|
*
|
||||||
* One might implement further decision rules for dealing with the security level (TCP or TLS)
|
* One might implement further decision rules for dealing with the security level (TCP or TLS)
|
||||||
* requested by the EVCC (see also Table 3 and 4 of ISO/IEC 15118-2). For now, the requested
|
* requested by the EVCC (see also Table 3 and 4 of ISO/IEC 15118-2). For now, the requested
|
||||||
* security level of the EVCC will always be accepted.
|
* security level of the EVCC will always be accepted.
|
||||||
*/
|
*/
|
||||||
byte[] seccAddress = (isSecureCommunication()) ? TLSServer.getInstance().getServerAddress().getAddress() : TCPServer.getInstance().getServerAddress().getAddress();
|
byte[] seccAddress = (isSecureCommunication()) ? TLSServer.getInstance().getServerAddress().getAddress() : TCPServer.getInstance().getServerAddress().getAddress();
|
||||||
int seccPort = (isSecureCommunication()) ? TLSServer.getInstance().getServerPort() : TCPServer.getInstance().getServerPort();
|
int seccPort = (isSecureCommunication()) ? TLSServer.getInstance().getServerPort() : TCPServer.getInstance().getServerPort();
|
||||||
|
|
||||||
SECCDiscoveryRes seccDiscoveryRes = new SECCDiscoveryRes(
|
SECCDiscoveryRes seccDiscoveryRes = new SECCDiscoveryRes(
|
||||||
seccAddress,
|
seccAddress,
|
||||||
ByteUtils.toByteArrayFromInt(seccPort, true),
|
ByteUtils.toByteArrayFromInt(seccPort, true),
|
||||||
getSecurity(),
|
getSecurity(),
|
||||||
GlobalValues.V2G_TRANSPORT_PROTOCOL_TCP.getByteValue()
|
GlobalValues.V2G_TRANSPORT_PROTOCOL_TCP.getByteValue()
|
||||||
);
|
);
|
||||||
|
|
||||||
setV2gTpMessage(new V2GTPMessage(GlobalValues.V2GTP_VERSION_1_IS.getByteValue(),
|
setV2gTpMessage(new V2GTPMessage(GlobalValues.V2GTP_VERSION_1_IS.getByteValue(),
|
||||||
GlobalValues.V2GTP_PAYLOAD_TYPE_SDP_RESPONSE_MESSAGE.getByteArrayValue(),
|
GlobalValues.V2GTP_PAYLOAD_TYPE_SDP_RESPONSE_MESSAGE.getByteArrayValue(),
|
||||||
seccDiscoveryRes.getPayload()));
|
seccDiscoveryRes.getPayload()));
|
||||||
|
|
||||||
getLogger().debug("Preparing to send SECCDiscoveryRes ...");
|
getLogger().debug("Preparing to send SECCDiscoveryRes ...");
|
||||||
|
|
||||||
// The SECCDiscoveryRes must be sent via UDP before the requested TCP/TLS server can be used
|
// The SECCDiscoveryRes must be sent via UDP before the requested TCP/TLS server can be used
|
||||||
UDPServer.getInstance().send(getV2gTpMessage(), (Inet6Address) udpClientPacket.getAddress(), udpClientPacket.getPort());
|
UDPServer.getInstance().send(getV2gTpMessage(), (Inet6Address) udpClientPacket.getAddress(), udpClientPacket.getPort());
|
||||||
} else {
|
} else {
|
||||||
getLogger().warn("Incoming DatagramPacket could not be identified as a SECCDiscoveryReq");
|
getLogger().warn("Incoming DatagramPacket could not be identified as a SECCDiscoveryReq");
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
getLogger().error("NullPointerException occurred while processing SECCDiscoveryReq", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public enum GlobalValues {
|
||||||
*/
|
*/
|
||||||
PASSPHRASE_FOR_CERTIFICATES_AND_KEYS("123456"),
|
PASSPHRASE_FOR_CERTIFICATES_AND_KEYS("123456"),
|
||||||
|
|
||||||
// Aliases for contract certificate chain and OEM provisioning certficiate chain
|
// Aliases for contract certificate chain and OEM provisioning certificate chain
|
||||||
ALIAS_CONTRACT_CERTIFICATE("contract_cert"),
|
ALIAS_CONTRACT_CERTIFICATE("contract_cert"),
|
||||||
ALIAS_OEM_PROV_CERTIFICATE("oem_prov_cert"),
|
ALIAS_OEM_PROV_CERTIFICATE("oem_prov_cert"),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue