I want to upload the device's x509 certificate to iothub and create a device (on iothub) with that certificate.
I'm having trouble finding information about it and to make things worse I'm doing it in Golang with a library that tries to replicate the SDK. The lib: https://github.com/amenzhinsky/iothub
My 1st question would be, do I have/need to add my Root CA to the iothub manually? How can I create the device (on iothhub) when trying to connect to the iothub and use/upload/import the device's certificate? (I will need to do this to multiple devices so this process has to be automated. I need to upload the device certificate when I start the real device)
The code is something like:
c, _ := iotdevice.NewFromX509(iotmqtt.New(), device_id, hostname, cert)
if err := client.Connect(context.Background()); err != nil {
fmt.Println("Error connecting to iothub: ", err)
return
}
And I get a message of not Authorized