1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2026-02-06 15:15:20 +01:00

3 Commits

Author SHA1 Message Date
Napsty
3186d26184 Add parameter (-S) for custom SSL/TLS protocol version 2020-06-05 14:50:32 +02:00
Napsty
a52c6a0b6c Add parameter (-S) for custom SSL/TLS protocol version 2020-06-05 14:48:39 +02:00
Napsty
ca6858ab22 Add parameter (-S) for custom SSL/TLS protocol version 2020-06-05 14:20:36 +02:00

View File

@@ -22,7 +22,7 @@
# Copyright (c) 2008 David Ligeret # Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin # Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider # Copyright (c) 2010 Branden Schneider
# Copyright (c) 2010-2021 Claudio Kuenzler # Copyright (c) 2010-2020 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic # Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers # Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin # Copyright (c) 2011 Ludovic Hutin
@@ -275,16 +275,6 @@
#@ Author : Claudio Kuenzler #@ Author : Claudio Kuenzler
#@ Reason : Add parameter (-S) for custom SSL/TLS protocol version #@ Reason : Add parameter (-S) for custom SSL/TLS protocol version
#@--------------------------------------------------- #@---------------------------------------------------
#@ Date : 20200710
#@ Author : Claudio Kuenzler
#@ Reason : Improve missing mandatory parameter error text (issue #47)
#@ Delete temporary openssl config file after use (issue #48)
#@---------------------------------------------------
#@ Date : 20210809
#@ Author : Claudio Kuenzler
#@ Reason : Fix TLSv1 usage (issue #51)
#@---------------------------------------------------
from __future__ import print_function from __future__ import print_function
import sys import sys
@@ -294,7 +284,7 @@ import re
import pkg_resources import pkg_resources
from optparse import OptionParser,OptionGroup from optparse import OptionParser,OptionGroup
version = '20210809' version = '20200605'
NS = 'root/cimv2' NS = 'root/cimv2'
hosturl = '' hosturl = ''
@@ -535,7 +525,7 @@ def getopts() :
help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS") help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS")
group2.add_option("-C", "--cimport", dest="cimport", help="CIM port (default 5989)", metavar="CIMPORT") group2.add_option("-C", "--cimport", dest="cimport", help="CIM port (default 5989)", metavar="CIMPORT")
group2.add_option("-S", "--sslproto", dest="sslproto", help="SSL/TLS protocol version to overwrite system default: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3", metavar="SSLPROTO") group2.add_option("-S", "--sslproto", dest="sslproto", help="SSL/TLS protocol version to overwrite system default: SSLv2, SSLv3, TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3", metavar="SSLPROTO")
group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \ group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \
metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown") metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown")
group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \ group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \
@@ -595,7 +585,7 @@ def getopts() :
mandatories = ['host', 'user', 'password'] mandatories = ['host', 'user', 'password']
for m in mandatories: for m in mandatories:
if not options.__dict__[m]: if not options.__dict__[m]:
print("mandatory option '" + m + "' not defined. read usage in help.\n") print("mandatory parameter '--" + m + "' is missing\n")
parser.print_help() parser.print_help()
sys.exit(-1) sys.exit(-1)
@@ -664,7 +654,7 @@ if cimport:
# Use non-default SSL protocol version # Use non-default SSL protocol version
if sslproto: if sslproto:
verboseoutput("Using non-default SSL protocol: "+sslproto) verboseoutput("Using non-default SSL protocol: "+sslproto)
allowed_protos = ["SSLv2", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"] allowed_protos = ["SSLv2", "SSLv3", "TLSv1.0", "TLSv1.1", "TLSv1.2", "TLSv1.3"]
if any(proto.lower() == sslproto.lower() for proto in allowed_protos): if any(proto.lower() == sslproto.lower() for proto in allowed_protos):
import os import os
sslconfpath = '/tmp/'+hostname+'_openssl.conf' sslconfpath = '/tmp/'+hostname+'_openssl.conf'
@@ -1023,10 +1013,6 @@ if perfdata:
if perf == '|': if perf == '|':
perf = '' perf = ''
# Cleanup temporary openssl config
if sslproto:
os.remove(sslconfpath)
if GlobalStatus == ExitOK : if GlobalStatus == ExitOK :
print("OK - Server: %s %s %s%s" % (server_info, SerialNumber, bios_info, perf)) print("OK - Server: %s %s %s%s" % (server_info, SerialNumber, bios_info, perf))