admin管理员组

文章数量:1122833

I am trying to use my SOAP API with Apache CXF, but the API requires SSL client certificates. I saw that there is some XML-Config you can use, but I would like to do this programmatically. Setting the sslContext within the tlsClientParameters doesn't seem to work either. This is my code:

val service = SoapyService()
val port = service.soapyPort

val cond = ClientProxy.getClient(port).conduit
(cond as HTTPConduit).apply {
    tlsClientParameters =
        TLSClientParameters().apply {
            sslContext = sslContextWithCert
        }
}
val result = port.login(username, password)

But the server terminates the connection during SSL handshake due to missing certificate.

I am trying to use my SOAP API with Apache CXF, but the API requires SSL client certificates. I saw that there is some XML-Config you can use, but I would like to do this programmatically. Setting the sslContext within the tlsClientParameters doesn't seem to work either. This is my code:

val service = SoapyService()
val port = service.soapyPort

val cond = ClientProxy.getClient(port).conduit
(cond as HTTPConduit).apply {
    tlsClientParameters =
        TLSClientParameters().apply {
            sslContext = sslContextWithCert
        }
}
val result = port.login(username, password)

But the server terminates the connection during SSL handshake due to missing certificate.

Share Improve this question asked Nov 22, 2024 at 14:50 Ian RehwinkelIan Rehwinkel 2,6155 gold badges27 silver badges61 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

With an SSLContext already present, we can easily get the SSLSocketFactory from that. Simply use sslSocketFactory = sslContextWithCert.socketFactory instead of sslContext = sslContextWithCert. This will make Apache CXF use the sockets from that factory, which (if you added your cert to that SSL context) will send the certificates with your requests.

本文标签: javaHow do I use a client certificate with Apache CXFStack Overflow