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

in WithX509Identity it 'll be nice to load cert/key through path #16

Closed
FranckEtienne opened this issue Mar 17, 2023 · 2 comments
Closed

Comments

@FranckEtienne
Copy link

Like "func WithClientCertificateFile(certPath, keyPath string) Option" it would be nice to be able to load cert/key to X509 identity:
WithX509Identity(CertPath, keyPath) Option

Is it a rapid alternative to load cert/key ?

Thank's

@FranckEtienne
Copy link
Author

I found how (but I must cast []byte to ua.ByteString?):
cert, err := tls.LoadX509KeyPair("./loki.crt", "./loki.pem")
if err != nil {
fmt.Printf("Error opening certs. %s\n", err.Error())
}
localCertificate := cert.Certificate[0]
localPrivateKey, _ := cert.PrivateKey.(*rsa.PrivateKey)

// open a connection to server running locally
ch, err := client.Dial(
	ctx,
	"opc.tcp://localhost.localdomain:48010",
	client.WithClientCertificate(localCertificate, localPrivateKey),
	client.WithInsecureSkipVerify(), // skips verification of server certificate
	client.WithX509Identity(**ua.ByteString(**localCertificate), localPrivateKey),

@FranckEtienne
Copy link
Author

Thank's.
It works fine, I already use it in version 1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants