blob: fe71d1b24c6b898700689dc17fc8f464c3a2681c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.ssl.impl;
import com.yahoo.component.annotation.Inject;
import com.yahoo.jdisc.http.ConnectorConfig;
import com.yahoo.jdisc.http.server.jetty.DataplaneProxyCredentials;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Optional;
/**
* Used to enable token based endpoints in Cloud. Amends trust store to allow proxy.
*
* @author mortent
*/
public class CloudTokenSslContextProvider extends ConfiguredSslContextFactoryProvider {
private final DataplaneProxyCredentials dataplaneProxyCredentials;
@Inject
public CloudTokenSslContextProvider(ConnectorConfig connectorConfig,
DataplaneProxyCredentials dataplaneProxyCredentials) {
super(connectorConfig);
this.dataplaneProxyCredentials = dataplaneProxyCredentials;
}
@Override
Optional<String> getCaCertificates(ConnectorConfig.Ssl sslConfig) {
try {
return Optional.of(Files.readString(dataplaneProxyCredentials.certificateFile(), StandardCharsets.UTF_8));
} catch (IOException e) {
throw new IllegalArgumentException("Dataplane proxy certificate not available", e);
}
}
}
|