Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificateType field type OCPP 1.6J security extension #301

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ocpp1.6/central_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ func (cs *centralSystem) SignedUpdateFirmware(clientId string, callback func(*se
return cs.SendRequestAsync(clientId, request, genericCallback)
}

func (cs *centralSystem) GetInstalledCertificateIds(clientId string, callback func(*certificates.GetInstalledCertificateIdsResponse, error), props ...func(request *certificates.GetInstalledCertificateIdsRequest)) error {
request := certificates.NewGetInstalledCertificateIdsRequest()
func (cs *centralSystem) GetInstalledCertificateIds(clientId string, callback func(*certificates.GetInstalledCertificateIdsResponse, error), certificateType types.CertificateUse, props ...func(request *certificates.GetInstalledCertificateIdsRequest)) error {
request := certificates.NewGetInstalledCertificateIdsRequest(certificateType)
for _, fn := range props {
fn(request)
}
Expand Down
6 changes: 3 additions & 3 deletions ocpp1.6/certificates/get_installed_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func isValidGetInstalledCertificateStatus(fl validator.FieldLevel) bool {

// The field definition of the GetInstalledCertificateIdsRequest PDU sent by the CSMS to the Charging Station.
type GetInstalledCertificateIdsRequest struct {
CertificateTypes []types.CertificateUse `json:"certificateType" validate:"omitempty,dive,certificateUse16"`
CertificateType types.CertificateUse `json:"certificateType" validate:"required,certificateUse16"`
}

// The field definition of the GetInstalledCertificateIds response payload sent by the Charging Station to the CSMS in response to a GetInstalledCertificateIdsRequest.
Expand Down Expand Up @@ -66,8 +66,8 @@ func (c GetInstalledCertificateIdsResponse) GetFeatureName() string {
}

// Creates a new GetInstalledCertificateIdsRequest, containing all required fields. There are no optional fields for this message.
func NewGetInstalledCertificateIdsRequest() *GetInstalledCertificateIdsRequest {
return &GetInstalledCertificateIdsRequest{}
func NewGetInstalledCertificateIdsRequest(certificateType types.CertificateUse) *GetInstalledCertificateIdsRequest {
return &GetInstalledCertificateIdsRequest{CertificateType: certificateType}
}

// Creates a new NewGetInstalledCertificateIdsResponse, containing all required fields. Additional optional fields may be set afterwards.
Expand Down
2 changes: 1 addition & 1 deletion ocpp1.6/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,6 @@ func init() {
_ = Validate.RegisterValidation("location16", isValidLocation)
_ = Validate.RegisterValidation("unitOfMeasure", isValidUnitOfMeasure)
_ = Validate.RegisterValidation("certificateSigningUse16", isValidCertificateSigningUse)
_ = Validate.RegisterValidation("isValidCertificateUse", isValidCertificateUse)
_ = Validate.RegisterValidation("certificateUse16", isValidCertificateUse)
_ = Validate.RegisterValidation("genericStatus16", isValidGenericStatus)
}
5 changes: 4 additions & 1 deletion ocpp1.6/v16.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,14 @@ type CentralSystem interface {
ClearChargingProfile(clientId string, callback func(*smartcharging.ClearChargingProfileConfirmation, error), props ...func(request *smartcharging.ClearChargingProfileRequest)) error
// Queries a charge point to the composite smart charging schedules and rules for a specified time interval.
GetCompositeSchedule(clientId string, callback func(*smartcharging.GetCompositeScheduleConfirmation, error), connectorId int, duration int, props ...func(request *smartcharging.GetCompositeScheduleRequest)) error

TriggerMessageExtended(clientId string, callback func(*extendedtriggermessage.ExtendedTriggerMessageResponse, error), requestedMessage extendedtriggermessage.ExtendedTriggerMessageType, props ...func(request *extendedtriggermessage.ExtendedTriggerMessageRequest)) error

CertificateSigned(clientId string, callback func(*security.CertificateSignedResponse, error), csr string, props ...func(request *security.CertificateSignedRequest)) error

InstallCertificate(clientId string, callback func(*certificates.InstallCertificateResponse, error), certificateType types.CertificateUse, certificate string, props ...func(request *certificates.InstallCertificateRequest)) error

GetInstalledCertificateIds(clientId string, callback func(*certificates.GetInstalledCertificateIdsResponse, error), props ...func(request *certificates.GetInstalledCertificateIdsRequest)) error
GetInstalledCertificateIds(clientId string, callback func(*certificates.GetInstalledCertificateIdsResponse, error), certificateType types.CertificateUse, props ...func(request *certificates.GetInstalledCertificateIdsRequest)) error

DeleteCertificate(clientId string, callback func(*certificates.DeleteCertificateResponse, error), certificateHashData types.CertificateHashData, props ...func(request *certificates.DeleteCertificateRequest)) error

Expand Down Expand Up @@ -353,6 +354,8 @@ func NewCentralSystem(endpoint *ocppj.Server, server ws.WsServer) CentralSystem
smartcharging.Profile,
logging.Profile,
security.Profile,
extendedtriggermessage.Profile,
certificates.Profile,
securefirmware.Profile,
)
}
Expand Down
1 change: 1 addition & 0 deletions ocppj/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (s *Server) SendError(clientID string, requestId string, errorCode ocpp.Err
return ocpp.NewError(GenericError, err.Error(), requestId)
}
log.Debugf("sent CALL ERROR [%s] for %s", callError.UniqueId, clientID)
log.Debugf("sent JSON message to %s: %s", clientID, string(jsonMessage))
return nil
}

Expand Down
Loading