Skip to content

Commit

Permalink
feat(plc4go/opcua): some progress on secure channel
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jul 27, 2023
1 parent 3931a66 commit 36673bd
Show file tree
Hide file tree
Showing 3 changed files with 641 additions and 14 deletions.
23 changes: 21 additions & 2 deletions plc4go/internal/opcua/EncryptionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package opcua

import readWriteModel "github.com/apache/plc4x/plc4go/protocols/opcua/readwrite/model"
import (
"crypto/x509"
readWriteModel "github.com/apache/plc4x/plc4go/protocols/opcua/readwrite/model"
)

type EncryptionHandler struct {
// TODO: implement me
Expand All @@ -29,6 +32,22 @@ func NewEncryptionHandler(any, []byte, string) *EncryptionHandler {
return &EncryptionHandler{}
}

func (h *EncryptionHandler) encodeMessage(messageRequest readWriteModel.OpcuaMessageRequest, bytes []byte) []byte {
func (h *EncryptionHandler) encodeMessage(messageRequest readWriteModel.MessagePDU, bytes []byte) []byte {
return nil
}

func (h *EncryptionHandler) decodeMessage(apu readWriteModel.OpcuaAPU) readWriteModel.OpcuaAPUExactly {
return nil
}

func (h *EncryptionHandler) getCertificateX509(senderCertificate []byte) x509.Certificate {
return x509.Certificate{}
}

func (h *EncryptionHandler) setServerCertificate(certificateX509 x509.Certificate) {
return
}

func (h *EncryptionHandler) encryptPassword(password []byte) []byte {
return nil
}
13 changes: 13 additions & 0 deletions plc4go/internal/opcua/MessageCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ func (m *MessageCodec) GetCodec() spi.MessageCodec {
return m
}

func (m *MessageCodec) Connect() error {
return m.ConnectWithContext(context.Background())
}

func (m *MessageCodec) ConnectWithContext(ctx context.Context) error {
if err := m.DefaultCodec.ConnectWithContext(ctx); err != nil {
return errors.Wrap(err, "error connecting default codec")
}
m.log.Debug().Msg("Opcua Driver running in ACTIVE mode.")
m.channel.onConnect(ctx, m)
return nil
}

func (m *MessageCodec) Send(message spi.Message) error {
m.log.Trace().Msgf("Sending message\n%s", message)
// Cast the message to the correct type of struct
Expand Down
Loading

0 comments on commit 36673bd

Please sign in to comment.