-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
In my case I have a DTLS server (using bouncy castle low level API), which need to support PSK, RPK and X509.
A peer which support X509 could support RPK too.
Of course, it should be possible to configure that peer in a way it only accept X509.
Currently, it seems there is a bug (or missing feature) which prevent to create a server which accept both.
A comment in the code seems to confirm that:
bc-java/tls/src/main/java/org/bouncycastle/tls/AbstractTlsServer.java
Lines 605 to 606 in 0e100a5
| // TODO An X509 certificate should still be usable as RawPublicKey | |
| short serverCertificateType = credentials.getCertificate().getCertificateType(); |
Maybe it make sense to try to find supported Server Certificate Type based on getCredentials() but in case this is X509 certificate, maybe RPK should be added too by default ?
Maybe we should have a getSupportedServerCertificateTypes() in AbstractTlsServer with default implementation based on getCredentials, so it would be easy to override it change default behavoir.
(Bonus question, as there is not so much documentation, it is often hard to know what is expected when implementing BC interface/abstract class, typically for getCredentials() should I a create a BcDefaultTlsCredentialedSigner on each call ? I guess at least 1 by handshake and so it should be simpler if getCredentials was called only 1 time by handshake ? currently it is called twice, 1 time to get Server Certificate Type and one time to store it ServerHandshakeState.serverCredentials)