class_docstr: Security configuration for a Dask cluster.
  
  Default values are loaded from Dask's configuration files, and can be
  overridden in the constructor.
  
  Parameters
  ----------
  require_encryption : bool, optional
      Whether TLS encryption is required for all connections.
  tls_ca_file : str, optional
      Path to a CA certificate file encoded in PEM format.
  tls_ciphers : str, optional
      An OpenSSL cipher string of allowed ciphers. If not provided, the
      system defaults will be used.
  tls_min_version : ssl.TLSVersion, optional
      The minimum TLS version to support. Defaults to TLS 1.2.
  tls_max_version : ssl.TLSVersion, optional
      The maximum TLS version to support. Defaults to the maximum version
      supported.
  tls_client_cert : str, optional
      Path to a certificate file for the client, encoded in PEM format.
  tls_client_key : str, optional
      Path to a key file for the client, encoded in PEM format.
      Alternatively, the key may be appended to the cert file, and this
      parameter be omitted.
  tls_scheduler_cert : str, optional
      Path to a certificate file for the scheduler, encoded in PEM format.
  tls_scheduler_key : str, optional
      Path to a key file for the scheduler, encoded in PEM format.
      Alternatively, the key may be appended to the cert file, and this
      parameter be omitted.
  tls_worker_cert : str, optional
      Path to a certificate file for a worker, encoded in PEM format.
  tls_worker_key : str, optional
      Path to a key file for a worker, encoded in PEM format.
      Alternatively, the key may be appended to the cert file, and this
      parameter be omitted.
  extra_conn_args : mapping, optional
      Mapping with keyword arguments to pass down to connections.
class_docstr_tok: ["Security","configuration","for","a","Dask","cluster",".","Default","values","are","loaded","from","Dask","'s","configuration","files",",","and","can","be","overridden","in","the","constructor",".","Parameters","--","--","--","--","--","require_encryption",":","bool",",","optional","Whether","TLS","encryption","is","required","for","all","connections",".","tls_ca_file",":","str",",","optional","Path","to","a","CA","certificate","file","encoded","in","PEM","format",".","tls_ciphers",":","str",",","optional","An","OpenSSL","cipher","string","of","allowed","ciphers",".","If","not","provided",",","the","system","defaults","will","be","used",".","tls_min_version",":","ssl.TLSVersion",",","optional","The","minimum","TLS","version","to","support",".","Defaults","to","TLS","1.2.","tls_max_version",":","ssl.TLSVersion",",","optional","The","maximum","TLS","version","to","support",".","Defaults","to","the","maximum","version","supported",".","tls_client_cert",":","str",",","optional","Path","to","a","certificate","file","for","the","client",",","encoded","in","PEM","format",".","tls_client_key",":","str",",","optional","Path","to","a","key","file","for","the","client",",","encoded","in","PEM","format",".","Alternatively",",","the","key","may","be","appended","to","the","cert","file",",","and","this","parameter","be","omitted",".","tls_scheduler_cert",":","str",",","optional","Path","to","a","certificate","file","for","the","scheduler",",","encoded","in","PEM","format",".","tls_scheduler_key",":","str",",","optional","Path","to","a","key","file","for","the","scheduler",",","encoded","in","PEM","format",".","Alternatively",",","the","key","may","be","appended","to","the","cert","file",",","and","this","parameter","be","omitted",".","tls_worker_cert",":","str",",","optional","Path","to","a","certificate","file","for","a","worker",",","encoded","in","PEM","format",".","tls_worker_key",":","str",",","optional","Path","to","a","key","file","for","a","worker",",","encoded","in","PEM","format",".","Alternatively",",","the","key","may","be","appended","to","the","cert","file",",","and","this","parameter","be","omitted",".","extra_conn_args",":","mapping",",","optional","Mapping","with","keyword","arguments","to","pass","down","to","connections","."]
docstr: Create a new temporary Security object.
  
  This creates a new self-signed key/cert pair suitable for securing
  communication for all roles in a Dask cluster. These keys/certs exist
  only in memory, and are stored in this object.
  
  This method requires the library ``cryptography`` be installed.
docstr_tok: ["Create","a","new","temporary","Security","object",".","This","creates","a","new","self-signed","key\/cert","pair","suitable","for","securing","communication","for","all","roles","in","a","Dask","cluster",".","These","keys\/certs","exist","only","in","memory",",","and","are","stored","in","this","object",".","This","method","requires","the","library","``","cryptography","``","be","installed","."]
code: def temporary(cls, **kwargs):
      """Create a new temporary Security object.
  
      This creates a new self-signed key/cert pair suitable for securing
      communication for all roles in a Dask cluster. These keys/certs exist
      only in memory, and are stored in this object.
  
      This method requires the library ``cryptography`` be installed.
      """
      try:
          from cryptography import x509
          from cryptography.hazmat.backends import default_backend
          from cryptography.hazmat.primitives import (
              hashes,
              serialization,
          )
          from cryptography.hazmat.primitives.asymmetric import rsa
          from cryptography.x509.oid import NameOID
      except ImportError:
          raise ImportError(
              "Using `Security.temporary` requires `cryptography`, please "
              "install it using either pip or conda"
          )
      key = rsa.generate_private_key(
          public_exponent=65537,
          key_size=2048,
          backend=default_backend(),
      )
      key_contents = key.private_bytes(
          encoding=serialization.Encoding.PEM,
          format=serialization.PrivateFormat.PKCS8,
          encryption_algorithm=serialization.NoEncryption(),
      ).decode()
  
      dask_internal = x509.Name(
          [x509.NameAttribute(NameOID.COMMON_NAME, "dask-internal")]
      )
      altnames = x509.SubjectAlternativeName(
          [x509.DNSName("dask-internal")]
      )
      now = datetime.datetime.now(tz=datetime.timezone.utc).replace(
          tzinfo=None
      )
      cert = (
          x509.CertificateBuilder()
          .subject_name(dask_internal)
          .issuer_name(dask_internal)
          .add_extension(altnames, critical=False)
          .public_key(key.public_key())
          .serial_number(x509.random_serial_number())
          .not_valid_before(now)
          .not_valid_after(now + datetime.timedelta(days=365))
          .sign(key, hashes.SHA256(), default_backend())
      )
  
      cert_contents = cert.public_bytes(
          serialization.Encoding.PEM
      ).decode()
  
      return cls(
          require_encryption=True,
          tls_ca_file=cert_contents,
          tls_client_key=key_contents,
          tls_client_cert=cert_contents,
          tls_scheduler_key=key_contents,
          tls_scheduler_cert=cert_contents,
          tls_worker_key=key_contents,
          tls_worker_cert=cert_contents,
          **kwargs,
      )
  
imports: from __future__ import annotations
  import datetime
  import os
  import ssl
  import sys
  import tempfile
  import warnings
  import dask
  from dask.widgets import get_template
label_desc: Use image node_id 2 for calling the Security obj's underlying member method code with example usage: obj.temporary(cls) and returns: cls