Skip to content

Commit 2b5dc94

Browse files
Add TLS version support via the -tls flag (#41)
* Add support for TLS version by adding the flag -tls * Update README.md --------- Co-authored-by: shiraya <[email protected]>
1 parent d6d8d48 commit 2b5dc94

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ that are being used (the ones that were installed on the security gateways).
5050
[-n port-number] (Optional): The port of WebAPI server on Security Management Server.
5151
Default value is 443.
5252

53+
[-tls tls-version] (Optional): The TLS protocol version used to connect to the Management server.
54+
Default value is 'TLSv1.2'.(e.g. -tls TLSv1.3)
55+
5356
[-o path] (Optional): The output path. The location in which to save the resulting .tar.gz file.
5457
The parameter can also be the full path (including the .tar.gz filename).
5558
The default is the current directory.

src/main/java/com/checkpoint/mgmt_api/examples/ShowPackageConfiguration.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public enum ShowPackageConfiguration {
9191
private FileHandler fileHandler;
9292
/*Paths settings*/
9393

94+
private static String tlsVersion = "TLSv1.2";
95+
9496
private static String tarGzPath = tarName;
9597
private static String resultFolderPath;
9698
//Define if the function needs only to show the existing packages
@@ -103,6 +105,20 @@ public enum ShowPackageConfiguration {
103105
private static boolean showEachRulesUid = false;
104106

105107
private static RandomAccessFile rulbaseWriter;
108+
109+
110+
public static String getTlsVersion() {
111+
return tlsVersion;
112+
}
113+
114+
public static void setTlsVersion(String tlsVersion) {
115+
if(tlsVersion==null)
116+
ShowPackageConfiguration.tlsVersion = "TLSv1.2";
117+
else {
118+
ShowPackageConfiguration.tlsVersion = tlsVersion;
119+
}
120+
}
121+
106122
void initializeParameters(String[] args) throws Exception{
107123

108124
//Default debug level
@@ -741,6 +757,17 @@ String value(){
741757
return "";
742758
}
743759
},
760+
tlsVersions("-tls") {
761+
void runCommand(String value) { tlsVersion = value;}
762+
void flagToString() { System.out.println("\tTLS Version. \n\tDefault value is TLSv1.2");}
763+
String debugString()
764+
{
765+
return "tlsVersions:(-tls)=" + tlsVersion;
766+
}
767+
String value(){
768+
return " tls-version";
769+
}
770+
},
744771
deleteTempFiles("-r") {
745772
void runCommand(String value)
746773
{

src/main/java/com/checkpoint/mgmt_api/examples/ShowPackageTool.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ShowPackageTool {
4646
final String HTTPS_PROTOCOLS_PROPERTY = "https.protocols";
4747

4848
if (System.getProperty(HTTPS_PROTOCOLS_PROPERTY) == null) {
49-
System.setProperty(HTTPS_PROTOCOLS_PROPERTY, "TLSv1,TLSv1.1,TLSv1.2");
49+
System.setProperty(HTTPS_PROTOCOLS_PROPERTY, "TLSv1,TLSv1.1,TLSv1.2,TLSv1.3");
5050
}
5151
}
5252

@@ -115,6 +115,12 @@ public static void main(String[] args) {
115115
apiClientArgs.setProxySetting(proxy);
116116
}
117117

118+
/*If the user asked for a certain tls version, then set the tls version to a given one*/
119+
String TlsVersion = configuration.getTlsVersion();
120+
if(TlsVersion != null && !TlsVersion.isEmpty()){
121+
apiClientArgs.setTlsVersion(TlsVersion);
122+
}
123+
118124
/*If the user asked for a certain port, then set the port to a given port*/
119125
if(configuration.isUserEnteredPort()){
120126
apiClientArgs.setPort(configuration.getPort());

0 commit comments

Comments
 (0)