Beispiel #1
0
# or with a friendly name (e.g. 'tls1.1')

# Set with enumeration constants
sock.set_ssl_version_range(ssl.SSL_LIBRARY_VERSION_TLS_1_1,
                           ssl.SSL_LIBRARY_VERSION_TLS_1_2)

print()
print("Socket version range after seting")
print("socket ssl version (asString): %s" %
      (sock.get_ssl_version_range(repr_kind=nss.AsString), ))
print("socket ssl version (asEnumName): %s" %
      (sock.get_ssl_version_range(repr_kind=nss.AsEnumName), ))
print("socket ssl version (asEnum): %s" % (sock.get_ssl_version_range(), ))

# Set with friendly names
ssl.set_default_ssl_version_range('tls1.1', 'tls1.2')

print()
print("default ssl version after resetting (asString): %s" %
      (ssl.get_default_ssl_version_range(repr_kind=nss.AsString), ))
print("default ssl version after resetting (asEnumName): %s" %
      (ssl.get_default_ssl_version_range(repr_kind=nss.AsEnumName), ))
print("default ssl version after resetting (asEnum): %s" %
      (ssl.get_default_ssl_version_range(), ))

# Illustrate mapping between version names and enumerations.
# Note, the repr_kind parameter to the get library version functions
# will also give you the option as to whether an enumerated constant
# or a name is returned.

names = [
# Set with enumeration constants
sock.set_ssl_version_range(ssl.SSL_LIBRARY_VERSION_TLS_1_1,
                           ssl.SSL_LIBRARY_VERSION_TLS_1_2)


print()
print("Socket version range after seting")
print("socket ssl version (asString): %s" % \
    (sock.get_ssl_version_range(repr_kind=nss.AsString),))
print("socket ssl version (asEnumName): %s" % \
    (sock.get_ssl_version_range(repr_kind=nss.AsEnumName),))
print("socket ssl version (asEnum): %s" % \
    (sock.get_ssl_version_range(),))

# Set with friendly names
ssl.set_default_ssl_version_range('tls1.1', 'tls1.2')

print()
print("default ssl version after resetting (asString): %s" % \
    (ssl.get_default_ssl_version_range(repr_kind=nss.AsString),))
print("default ssl version after resetting (asEnumName): %s" % \
    (ssl.get_default_ssl_version_range(repr_kind=nss.AsEnumName),))
print("default ssl version after resetting (asEnum): %s" % \
    (ssl.get_default_ssl_version_range(),))

# Illustrate mapping between version names and enumerations.
# Note, the repr_kind parameter to the get library version functions
# will also give you the option as to whether an enumerated constant
# or a name is returned.

names = [
Beispiel #3
0
min_ssl_version, max_ssl_version = ssl.get_default_ssl_version_range(
    repr_kind=nss.AsString)
print("Default SSL version range: min=%s, max=%s" %
      (min_ssl_version, max_ssl_version))

if options.min_ssl_version is not None or options.max_ssl_version is not None:

    if options.min_ssl_version is not None:
        min_ssl_version = options.min_ssl_version
    if options.max_ssl_version is not None:
        max_ssl_version = options.max_ssl_version

    print("Setting default SSL version range: min=%s, max=%s" %
          (min_ssl_version, max_ssl_version))
    ssl.set_default_ssl_version_range(min_ssl_version, max_ssl_version)

    min_ssl_version, max_ssl_version = ssl.get_default_ssl_version_range(
        repr_kind=nss.AsString)
    print("Default SSL version range now: min=%s, max=%s" %
          (min_ssl_version, max_ssl_version))

# Run as a client or as a serveri
if options.client:
    print("starting as client")
    Client()

if options.server:
    print("starting as server")
    Server()
Beispiel #4
0
min_ssl_version, max_ssl_version = \
    ssl.get_default_ssl_version_range(repr_kind=nss.AsString)
print("Default SSL version range: min=%s, max=%s" % \
    (min_ssl_version, max_ssl_version))

if options.min_ssl_version is not None or \
   options.max_ssl_version is not None:

    if options.min_ssl_version is not None:
        min_ssl_version  = options.min_ssl_version
    if options.max_ssl_version is not None:
        max_ssl_version  = options.max_ssl_version

    print("Setting default SSL version range: min=%s, max=%s" % \
        (min_ssl_version, max_ssl_version))
    ssl.set_default_ssl_version_range(min_ssl_version, max_ssl_version)

    min_ssl_version, max_ssl_version = \
        ssl.get_default_ssl_version_range(repr_kind=nss.AsString)
    print("Default SSL version range now: min=%s, max=%s" % \
        (min_ssl_version, max_ssl_version))

# Run as a client or as a serveri
if options.client:
    print("starting as client")
    Client()

if options.server:
    print("starting as server")
    Server()