I have auto provisioned a bunch of IoT devices via Azure IoT DPS. The devices are registered at my IoT hub. All devices have an X.509 certificate authentication.
What I now want to do is to send messages to the devices. All certificates are available and I can connect with the DeviceClient to the device at the hub. This is the method of the Azure IoT Java SDK I am using:
public static DeviceClient createFromSecurityProvider(String uri, String deviceId, SecurityProvider securityProvider, IotHubClientProtocol protocol) throws URISyntaxException, IOException
It takes SecurityProviderX509Cert as parameter.
However, each DeviceClient has its own physical connection. What I want is to use AMQP multiplexing by using this constructor:
public DeviceClient(String connString, TransportClient transportClient) throws URISyntaxException
This doesn't work with X.509 devices. In the connection string I've used the shared access key from my shared access policy from the hub but got an exception:
Unauthorized: Device 'xxx' at IotHub 'yyy' does not have PrimaryKey or SecondaryKey
I assume that will only work if I register the device with symmetric keys. However, those devices cannot be enrolled automatically via Azure DPS. I can only enroll devices with X.509 or TPM.
So how do I get the trick to connect multiple X.509 devices over a single AMQPS connection?