Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,21 @@ jobs:
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
encrypt --kas-url=localhost:8080 --mime-type=text/plain --attr https://example.com/attr/attr1/value/value1 --autoconfigure=false -f data -m 'here is some metadata' > test.tdf

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
decrypt -f test.tdf > decrypted

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
metadata -f test.tdf > metadata

if ! diff -q data decrypted; then
Expand All @@ -174,14 +174,14 @@ jobs:
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
encryptnano --kas-url=http://localhost:8080 --attr https://example.com/attr/attr1/value/value1 -f data -m 'here is some metadata' > nano.ntdf

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
decryptnano -f nano.ntdf > decrypted

if ! diff -q data decrypted; then
Expand Down Expand Up @@ -216,21 +216,21 @@ jobs:
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
encrypt --kas-url=localhost:8080,localhost:8282 -f data -m 'here is some metadata' > test.tdf

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
decrypt -f test.tdf > decrypted

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
-i -h \
metadata -f test.tdf > metadata

if ! diff -q data decrypted; then
Expand Down
24 changes: 20 additions & 4 deletions cmdline/src/main/java/io/opentdf/platform/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;

import nl.altindag.ssl.SSLFactory;
import nl.altindag.ssl.util.TrustManagerUtils;

import javax.net.ssl.TrustManager;

@CommandLine.Command(name = "tdf")
class Command {

@Option(names = {"--client-secret"}, required = true)
private String clientSecret;

@Option(names = {"-i", "--insecure-connection"}, defaultValue = "false")
@Option(names = {"-h", "--plaintext"}, defaultValue = "false")
private boolean plaintext;

@Option(names = {"-i", "--insecure"}, defaultValue = "false")
private boolean insecure;

@Option(names = {"--client-id"}, required = true)
Expand All @@ -63,6 +71,7 @@ void encrypt(
ki.URL = k;
return ki;
}).toArray(Config.KASInfo[]::new);


List<Consumer<Config.TDFConfig>> configs = new ArrayList<>();
configs.add(Config.withKasInformation(kasInfos));
Expand All @@ -84,10 +93,17 @@ void encrypt(
}

private SDK buildSDK() {
return new SDKBuilder()
.platformEndpoint(platformEndpoint)
SDKBuilder builder = new SDKBuilder();
if (insecure){
SSLFactory sslFactory = SSLFactory.builder()
.withUnsafeTrustMaterial() // Trust all certificates
.build();
builder.sslFactory(sslFactory);
}

return builder.platformEndpoint(platformEndpoint)
.clientSecret(clientId, clientSecret)
.useInsecurePlaintextConnection(insecure)
.useInsecurePlaintextConnection(plaintext)
.build();
}

Expand Down