|
@@ -1618,6 +1618,140 @@ int syncDateTimeRTC(uint8_t *data)
|
|
|
return result.result;
|
|
|
}
|
|
|
|
|
|
+//==========================================
|
|
|
+// Parse certificate content
|
|
|
+//==========================================
|
|
|
+int parseCertInfo(char *certPath, int parseType, char *data)
|
|
|
+{
|
|
|
+ int result = FAIL;
|
|
|
+ if(access(certPath,F_OK) != -1)
|
|
|
+ {
|
|
|
+ char temp[512] = {0};
|
|
|
+ char capturedData[256] = {0};
|
|
|
+ char hashType[10] = "SHA256";
|
|
|
+ FILE *fp;
|
|
|
+
|
|
|
+ // Need to get hash type first
|
|
|
+ sprintf(temp ,"openssl x509 -noout -text -in %s", certPath);
|
|
|
+ fp = popen(temp, "r");
|
|
|
+ if(fp)
|
|
|
+ {
|
|
|
+ while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(temp, "Signature Algorithm:") != NULL)
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+ if(strstr(temp, "sha256") != NULL || strstr(temp, "SHA256") != NULL)
|
|
|
+ sprintf((char*)hashType, "SHA256");
|
|
|
+ else if(strstr(temp, "sha384") != NULL || strstr(temp, "SHA384") != NULL)
|
|
|
+ sprintf((char*)hashType, "SHA384");
|
|
|
+ else if(strstr(temp, "sha512") != NULL || strstr(temp, "SHA512") != NULL)
|
|
|
+ sprintf((char*)hashType, "SHA512");
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Error: hashAlgorithm is illegal or missing.\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sprintf((char*)data, hashType);
|
|
|
+ }
|
|
|
+
|
|
|
+ switch(parseType)
|
|
|
+ {
|
|
|
+ case CERT_PARSE_HashAlgorithm:
|
|
|
+ // Already parsed
|
|
|
+ DEBUG_INFO("hashAlgorithm: %s\n", hashType);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CERT_PARSE_SerialNumber:
|
|
|
+ sprintf(temp ,"openssl x509 -noout -serial -in %s", certPath);
|
|
|
+ fp = popen(temp, "r");
|
|
|
+ if(fp)
|
|
|
+ {
|
|
|
+ while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(temp, "serial=") != NULL)
|
|
|
+ {
|
|
|
+ sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
+ result = PASS;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DEBUG_INFO("serialNumber: %s\n", capturedData);
|
|
|
+ sprintf((char*)data, capturedData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CERT_PARSE_IssuerNameHash:
|
|
|
+ sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", certPath, (char*)hashType);
|
|
|
+ fp = popen(temp, "r");
|
|
|
+ if(fp)
|
|
|
+ {
|
|
|
+ while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(temp, "(stdin)=") != NULL)
|
|
|
+ {
|
|
|
+ sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
+ result = PASS;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stringtrimspace(capturedData);
|
|
|
+ DEBUG_INFO("issuerNameHash: %s\n", capturedData);
|
|
|
+ sprintf((char*)data, capturedData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CERT_PARSE_IssuerKeyHash:
|
|
|
+ sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", certPath, (char*)hashType);
|
|
|
+ fp = popen(temp, "r");
|
|
|
+ if(fp)
|
|
|
+ {
|
|
|
+ while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(temp, "(stdin)=") != NULL)
|
|
|
+ {
|
|
|
+ sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
+ result = PASS;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stringtrimspace(capturedData);
|
|
|
+ DEBUG_INFO("issuerKeyHash: %s\n", capturedData);
|
|
|
+ sprintf((char*)data, capturedData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CERT_PARSE_OcspUrl:
|
|
|
+ sprintf(temp ,"openssl x509 -noout -ocsp_uri -in %s", certPath);
|
|
|
+ fp = popen(temp, "r");
|
|
|
+ if(fp)
|
|
|
+ {
|
|
|
+ while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(temp, "://") != NULL)
|
|
|
+ {
|
|
|
+ strcpy((char*)data, temp);
|
|
|
+ result = PASS;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ DEBUG_INFO("Parse type is invalid.\n");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pclose(fp);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//==========================================
|
|
|
// GetCompositeSchedule logic related function
|
|
|
//==========================================
|
|
@@ -5160,7 +5294,7 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
uint8_t ts[36];
|
|
|
getNowDatetime(ts);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, "org.openchargealliance.costmsg");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, strlen((char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor)>0? (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor:"org.openchargealliance.costmsg");
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ConnectorUnplugged");
|
|
|
if(strcmp((char*)dmsVersion, "2.0")==0)
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"transactionId\\\":%d,\\\"timestamp\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ts);
|
|
@@ -5226,7 +5360,7 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
uint8_t ts[36];
|
|
|
getNowDatetime(ts);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, "org.openchargealliance.costmsg");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, strlen((char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor)>0? (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor:"org.openchargealliance.costmsg");
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ConnectorUnplugged");
|
|
|
if(strcmp((char*)dmsVersion, "2.0")==0)
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"transactionId\\\":%d,\\\"timestamp\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ts);
|
|
@@ -5292,7 +5426,7 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
uint8_t ts[36];
|
|
|
getNowDatetime(ts);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, "org.openchargealliance.costmsg");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, strlen((char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor)>0? (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor:"org.openchargealliance.costmsg");
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ConnectorUnplugged");
|
|
|
if(strcmp((char*)dmsVersion, "2.0")==0)
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"transactionId\\\":%d,\\\"timestamp\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ts);
|
|
@@ -5350,7 +5484,7 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
uint8_t ts[36];
|
|
|
getNowDatetime(ts);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, "org.openchargealliance.costmsg");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, strlen((char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor)>0? (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor:"org.openchargealliance.costmsg");
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ConnectorUnplugged");
|
|
|
if(strcmp((char*)dmsVersion, "2.0")==0)
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"transactionId\\\":%d,\\\"timestamp\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ts);
|
|
@@ -5415,7 +5549,7 @@ void CheckSystemValue(void)
|
|
|
{
|
|
|
uint8_t ts[36];
|
|
|
getNowDatetime(ts);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, "org.openchargealliance.costmsg");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].VendorId, strlen((char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor)>0? (char*)ShmSysConfigAndInfo->SysConfig.chargePointVendor:"org.openchargealliance.costmsg");
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].MessageId, "ConnectorUnplugged");
|
|
|
if(strcmp((char*)dmsVersion, "2.0")==0)
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[gun_index].Data, "{\\\"transactionId\\\":%d,\\\"timestamp\\\":\\\"%s\\\"}", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId, ts);
|
|
@@ -5753,6 +5887,7 @@ void CheckSystemValue(void)
|
|
|
if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP16Data->v2g_extend.AuthorizeReq == 1))
|
|
|
{
|
|
|
memset(&ShmOCPP16Data->v2g_extend.Authorize.Response_idTokenInfo,0,sizeof(struct IdTokenInfoType));
|
|
|
+ int parseCertResult = FAIL;
|
|
|
|
|
|
json_object *data = json_object_new_object();
|
|
|
json_object *idToken = json_object_new_object();
|
|
@@ -5765,6 +5900,22 @@ void CheckSystemValue(void)
|
|
|
json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP16Data->v2g_extend.Authorize.idToken.idToken));
|
|
|
json_object_object_add(data, "idToken", idToken);
|
|
|
|
|
|
+ char parseData[512] = {0};
|
|
|
+ if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_HashAlgorithm, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[0].hashAlgorithm, parseData);
|
|
|
+
|
|
|
+ if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_SerialNumber, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[0].serialNumber, parseData);
|
|
|
+
|
|
|
+ if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_IssuerNameHash, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[0].issuerNameHash, parseData);
|
|
|
+
|
|
|
+ if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[0].issuerKeyHash, parseData);
|
|
|
+
|
|
|
+ if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_OcspUrl, parseData) == PASS)
|
|
|
+ strcpy((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[0].responderURL, parseData);
|
|
|
+
|
|
|
for(int idx=0; idx < 4; idx++)
|
|
|
{
|
|
|
if(strlen((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[idx].responderURL) >= 7)
|
|
@@ -5777,17 +5928,28 @@ void CheckSystemValue(void)
|
|
|
json_object_object_add(OCSPRequestDataType, "responderURL", json_object_new_string((char*)ShmOCPP16Data->v2g_extend.Authorize.iso15118CertificateHashData[idx].responderURL));
|
|
|
|
|
|
json_object_array_add(iso15118CertificateHashData, OCSPRequestDataType);
|
|
|
+ parseCertResult = PASS;
|
|
|
}
|
|
|
}
|
|
|
- json_object_object_add(data, "iso15118CertificateHashData", iso15118CertificateHashData);
|
|
|
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "org.openchargealliance.iso15118pnc");
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"Authorize");
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, "%s", json_object_to_json_string_ext(data, JSON_C_TO_STRING_PLAIN));
|
|
|
- json_object_put(data);
|
|
|
+ if(parseCertResult == PASS)
|
|
|
+ {
|
|
|
+ json_object_object_add(data, "iso15118CertificateHashData", iso15118CertificateHashData);
|
|
|
|
|
|
- ShmOCPP16Data->CsMsg.bits[0].DataTransferReq = 1;
|
|
|
- ShmOCPP16Data->v2g_extend.AuthorizeReq = 0;
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "org.openchargealliance.iso15118pnc");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"Authorize");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].Data, "%s", json_object_to_json_string_ext(data, JSON_C_TO_STRING_PLAIN));
|
|
|
+ json_object_put(data);
|
|
|
+
|
|
|
+ ShmOCPP16Data->CsMsg.bits[0].DataTransferReq = 1;
|
|
|
+ ShmOCPP16Data->v2g_extend.AuthorizeReq = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.Response_certificateStatus, "NoCertificateAvailable");
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.Authorize.Response_idTokenInfo.status, "Invalid");
|
|
|
+ ShmOCPP16Data->v2g_extend.AuthorizeConf = 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP16Data->v2g_extend.Get15118EVCertificateReq == 1))
|
|
@@ -12034,13 +12196,17 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
json_object *data;
|
|
|
data = json_tokener_parse(tempdata);
|
|
|
-
|
|
|
+ DEBUG_INFO("DeleteCertificate processing...\n");
|
|
|
if(!is_error(data))
|
|
|
{
|
|
|
- sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "hashAlgorithm")));
|
|
|
- sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerNameHash")));
|
|
|
- sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerKeyHash")));
|
|
|
- sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "serialNumber")));
|
|
|
+ if(json_object_object_get(json_object_object_get(data, "certificateHashData"), "hashAlgorithm") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "hashAlgorithm")));
|
|
|
+ if(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerNameHash") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerNameHash")));
|
|
|
+ if(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerKeyHash") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "issuerKeyHash")));
|
|
|
+ if(json_object_object_get(json_object_object_get(data, "certificateHashData"), "serialNumber") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(data, "certificateHashData"), "serialNumber")));
|
|
|
|
|
|
DEBUG_INFO("hashAlgorithm: %s\n", ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
DEBUG_INFO("issuerNameHash: %s\n", ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerNameHash);
|
|
@@ -12050,58 +12216,25 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
char temp[256] = {0};
|
|
|
char compareData[256] = {0};
|
|
|
int isMatch = TRUE;
|
|
|
- FILE *fp;
|
|
|
|
|
|
// Check certV2G
|
|
|
if(access(CERTIFICATE_V2G,F_OK) != -1)
|
|
|
{
|
|
|
- isMatch = FALSE;
|
|
|
- sprintf(temp ,"openssl x509 -noout -serial -in %s", CERTIFICATE_V2G);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "serial=") != NULL)
|
|
|
- {
|
|
|
- DEBUG_INFO("Certificate enddate info: %s\n", temp);
|
|
|
- sscanf(temp, "%*[^=]=%s", compareData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(strcmp(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
|
|
|
+ parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_SerialNumber, compareData);
|
|
|
+ if(strcmp(compareData, (char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.serialNumber) != 0)
|
|
|
isMatch = FALSE;
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", CERTIFICATE_V2G, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) == NULL)
|
|
|
+ parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_IssuerNameHash, compareData);
|
|
|
+ if(strstr(compareData, (char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", CERTIFICATE_V2G, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
|
|
|
+ parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_IssuerKeyHash, compareData);
|
|
|
+ if(strstr(compareData, (char*)ShmOCPP16Data->v2g_extend.DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
|
|
|
@@ -12181,7 +12314,9 @@ int handleDataTransferRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
char tempCert[] = "/Storage/OCPP/tempInstallCertificate.pem";
|
|
|
|
|
|
- sprintf((char*)ShmOCPP16Data->v2g_extend.InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(data, "certificateType")));
|
|
|
+ if(json_object_object_get(data, "certificateType") != NULL)
|
|
|
+ sprintf((char*)ShmOCPP16Data->v2g_extend.InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(data, "certificateType")));
|
|
|
+ if(json_object_object_get(data, "certificate") != NULL)
|
|
|
sprintf((char*)ShmOCPP16Data->v2g_extend.InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(data, "certificate")));
|
|
|
DEBUG_INFO("certificateType: %s\n", (char*)ShmOCPP16Data->v2g_extend.InstallCertificate.certificateType);
|
|
|
DEBUG_INFO("certificate: %s\n", (char*)ShmOCPP16Data->v2g_extend.InstallCertificate.certificate);
|
|
@@ -15832,51 +15967,20 @@ int handleDeleteCertificateRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
// Check CentralSystemRootCertificate
|
|
|
DEBUG_INFO("Checking CentralSystemRootCertificate...\n");
|
|
|
- sprintf(temp ,"openssl x509 -noout -serial -in %s", ROOTCA_CS);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "serial=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", compareData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- DEBUG_INFO("SerialNumber= %s...\n", compareData);
|
|
|
- }
|
|
|
+ parseCertInfo(ROOTCA_CS, CERT_PARSE_SerialNumber, compareData);
|
|
|
if(strcmp(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
|
|
|
isMatch = FALSE;
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", ROOTCA_CS, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) == NULL)
|
|
|
+ parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerNameHash, compareData);
|
|
|
+ if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", ROOTCA_CS, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
+ parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerKeyHash, compareData);
|
|
|
if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
@@ -15893,52 +15997,21 @@ int handleDeleteCertificateRequest(char *uuid, char *payload)
|
|
|
// Check ManufacturerRootCertificate
|
|
|
if(access(ROOTCA_MFG,F_OK) != -1)
|
|
|
{
|
|
|
- isMatch = FALSE;
|
|
|
- sprintf(temp ,"openssl x509 -noout -serial -in %s", ROOTCA_MFG);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "serial=") != NULL)
|
|
|
- {
|
|
|
- DEBUG_INFO("Certificate enddate info: %s\n", temp);
|
|
|
- sscanf(temp, "%*[^=]=%s", compareData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ isMatch = TRUE;
|
|
|
+ parseCertInfo(ROOTCA_MFG, CERT_PARSE_SerialNumber, compareData);
|
|
|
if(strcmp(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
|
|
|
isMatch = FALSE;
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", ROOTCA_MFG, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
- if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.serialNumber) == NULL)
|
|
|
+ parseCertInfo(ROOTCA_MFG, CERT_PARSE_IssuerNameHash, compareData);
|
|
|
+ if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
|
|
|
|
if(isMatch == TRUE)
|
|
|
{
|
|
|
- memset(compareData, 0, ARRAY_SIZE(compareData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", ROOTCA_MFG, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.hashAlgorithm);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- strcat(compareData, temp);
|
|
|
- }
|
|
|
- }
|
|
|
+ parseCertInfo(ROOTCA_MFG, CERT_PARSE_IssuerKeyHash, compareData);
|
|
|
if(strstr(compareData, (char*)ShmOCPP16Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
|
|
|
isMatch = FALSE;
|
|
|
}
|
|
@@ -16159,89 +16232,21 @@ int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
|
|
|
DEBUG_INFO("Requested Certificate: %s\n", (char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType);
|
|
|
sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_status, "Accepted");
|
|
|
|
|
|
- char temp[512] = {0};
|
|
|
- char capturedData[256] = {0};
|
|
|
- char hashType[10] = {0};
|
|
|
- FILE *fp;
|
|
|
-
|
|
|
// Check CentralSystemRootCertificate
|
|
|
if((strstr((char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType, "CentralSystemRootCertificate")!= NULL) && (access(ROOTCA_CS,F_OK) != -1))
|
|
|
{
|
|
|
- memset(hashType, 0, ARRAY_SIZE(hashType));
|
|
|
- sprintf(temp ,"openssl x509 -noout -text -in %s", ROOTCA_CS);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "Signature Algorithm:") != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "sha256") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA256");
|
|
|
- if(strstr(temp, "sha384") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA384");
|
|
|
- if(strstr(temp, "sha512") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA512");
|
|
|
+ char parseData[512] = {0};
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, CERT_PARSE_HashAlgorithm, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].hashAlgorithm, parseData);
|
|
|
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- DEBUG_INFO("hashAlgorithm: %s\n", hashType);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].hashAlgorithm, hashType);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, CERT_PARSE_SerialNumber, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].serialNumber, parseData);
|
|
|
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -serial -in %s", ROOTCA_CS);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "serial=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- DEBUG_INFO("serialNumber: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].serialNumber, capturedData);
|
|
|
- }
|
|
|
-
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", ROOTCA_CS, (char*)hashType);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "(stdin)=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- stringtrimspace(capturedData);
|
|
|
- DEBUG_INFO("issuerNameHash: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerNameHash, capturedData);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, CERT_PARSE_IssuerNameHash, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerNameHash, parseData);
|
|
|
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", ROOTCA_CS, (char*)hashType);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "(stdin)=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- stringtrimspace(capturedData);
|
|
|
- DEBUG_INFO("issuerKeyHash: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerKeyHash, capturedData);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerKeyHash, parseData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -16252,81 +16257,18 @@ int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
|
|
|
// Check ManufacturerRootCertificate
|
|
|
if((strstr((char*)ShmOCPP16Data->GetInstalledCertificateIds.certificateType, "ManufacturerRootCertificate") != NULL) && (access(ROOTCA_MFG,F_OK) != -1))
|
|
|
{
|
|
|
- memset(hashType, 0, ARRAY_SIZE(hashType));
|
|
|
- sprintf(temp ,"openssl x509 -noout -text -in %s", ROOTCA_MFG);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "Signature Algorithm:") != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "sha256") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA256");
|
|
|
- if(strstr(temp, "sha384") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA384");
|
|
|
- if(strstr(temp, "sha512") != NULL)
|
|
|
- sprintf((char*)hashType, "SHA512");
|
|
|
+ char parseData[512] = {0};
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, 1, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].hashAlgorithm, parseData);
|
|
|
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- DEBUG_INFO("hashAlgorithm: %s\n", hashType);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].hashAlgorithm, hashType);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, 1, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].serialNumber, parseData);
|
|
|
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -serial -in %s", ROOTCA_MFG);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "serial=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- DEBUG_INFO("serialNumber: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].serialNumber, capturedData);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, 1, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerNameHash, parseData);
|
|
|
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -issuer -in %s | openssl dgst -%s", ROOTCA_MFG, (char*)hashType);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "(stdin)=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- stringtrimspace(capturedData);
|
|
|
- DEBUG_INFO("issuerNameHash: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerNameHash, capturedData);
|
|
|
- }
|
|
|
-
|
|
|
- memset(capturedData, 0, ARRAY_SIZE(capturedData));
|
|
|
- sprintf(temp ,"openssl x509 -noout -pubkey -in %s | openssl dgst -%s", ROOTCA_MFG, (char*)hashType);
|
|
|
- fp = popen(temp, "r");
|
|
|
- if(fp)
|
|
|
- {
|
|
|
- while(fgets(temp, sizeof(temp), fp) != NULL)
|
|
|
- {
|
|
|
- if(strstr(temp, "(stdin)=") != NULL)
|
|
|
- {
|
|
|
- sscanf(temp, "%*[^=]=%s", capturedData);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- stringtrimspace(capturedData);
|
|
|
- DEBUG_INFO("issuerKeyHash: %s\n", capturedData);
|
|
|
- sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerKeyHash, capturedData);
|
|
|
- }
|
|
|
+ if(parseCertInfo(ROOTCA_MFG, 1, parseData) == PASS)
|
|
|
+ sprintf((char*)ShmOCPP16Data->GetInstalledCertificateIds.Response_certificateHashData[0].issuerKeyHash, parseData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -16739,6 +16681,7 @@ int handleInstallCertificateRequest(char *uuid, char *payload)
|
|
|
if(strstr(temp, "://") != NULL)
|
|
|
{
|
|
|
strcpy(ocspUrl, temp);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|