Skip to content

Commit 2ba1e9a

Browse files
author
Sepideh Roghanchi
committed
Init
1 parent 83c5603 commit 2ba1e9a

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/nfsv4mountscript.sh

+30-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ CERT_PATH=
2727
CERT_UPDATE_COMMAND=
2828
STUNNEL_CAFILE=
2929

30+
ssl_version=
31+
3032
# TODO: Might have to use portmap entry in future to determine the CONNECT_PORT for nfsv3.
3133
CONNECT_PORT=2049
3234

@@ -184,12 +186,13 @@ add_stunnel_configuration()
184186
return 1
185187
fi
186188

187-
# TODO: Change to TLSv1.3 once we have TLSv1.3 version enabled.
188-
echo "sslVersion = TLSv1.2" >> $stunnel_conf_file
189-
if [ $? -ne 0 ]; then
190-
chattr -f +i $stunnel_conf_file
191-
eecho "Failed to add sslVersion option to $stunnel_conf_file!"
192-
return 1
189+
if [ -n "$ssl_version" ]; then
190+
echo "sslVersion = TLSv${ssl_version}" >> $stunnel_conf_file
191+
if [ $? -ne 0 ]; then
192+
chattr -f +i $stunnel_conf_file
193+
eecho "Failed to add sslVersion option to $stunnel_conf_file!"
194+
return 1
195+
fi
193196
fi
194197

195198
echo "debug = $DEBUG_LEVEL" >> $stunnel_conf_file
@@ -308,6 +311,27 @@ tls_nfsv4_files_share_mount()
308311
local container
309312
local extra
310313

314+
# Check if user has provided SSLVersion in the mount options.
315+
if [[ "$MOUNT_OPTIONS" == *"tls"* ]]; then
316+
317+
ssl_version=$(echo "$MOUNT_OPTIONS" | grep -oE 'tls=[^,]+' | awk -F= '{print $2}')
318+
319+
# Check if SSL version is either 1.2 or 1.3
320+
if [[ "$ssl_version" == "1.2" || "$ssl_version" == "1.3" ]]; then
321+
echo "TLS version option: $ssl_version"
322+
else
323+
echo "No valid TLS version. Please provide a valid TLS version (1.2 or 1.3)."
324+
exit 1
325+
fi
326+
327+
# Remove the tls option from MOUNT_OPTIONS.
328+
if [[ "$MOUNT_OPTIONS" == *"tls=${ssl_version},"* ]]; then
329+
MOUNT_OPTIONS=${MOUNT_OPTIONS//tls=$ssl_version,/}
330+
else
331+
MOUNT_OPTIONS=${MOUNT_OPTIONS//,tls=$ssl_version/}
332+
fi
333+
fi
334+
311335
# Set trap to cleanup the lock on mountmap file on exit.
312336
trap 'cleanup' EXIT
313337

0 commit comments

Comments
 (0)