Ejemplo n.º 1
0
def channel_credentials_ssl(root_certificates, private_key, certificate_chain):
    pair = None
    if private_key is not None or certificate_chain is not None:
        pair = cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    if root_certificates is None:
        root_certificates = pkg_resources.resource_string(__name__, _ROOT_CERTIFICATES_RESOURCE_PATH)
    return cygrpc.channel_credentials_ssl(root_certificates, pair)
Ejemplo n.º 2
0
 def setUp(self):
   server_credentials = cygrpc.server_credentials_ssl(
       None, [cygrpc.SslPemKeyCertPair(resources.private_key(),
                                       resources.certificate_chain())], False)
   client_credentials = cygrpc.channel_credentials_ssl(
       resources.test_root_certificates(), None)
   self.setUpMixin(server_credentials, client_credentials, _SSL_HOST_OVERRIDE)
Ejemplo n.º 3
0
def channel_credentials_ssl(root_certificates, private_key, certificate_chain):
    pair = None
    if private_key is not None or certificate_chain is not None:
        pair = cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    if root_certificates is None:
        root_certificates = pkg_resources.resource_string(
            __name__, _ROOT_CERTIFICATES_RESOURCE_PATH)
    return cygrpc.channel_credentials_ssl(root_certificates, pair)
Ejemplo n.º 4
0
 def setUp(self):
   server_credentials = cygrpc.server_credentials_ssl(
       None, [cygrpc.SslPemKeyCertPair(resources.private_key(),
                                       resources.certificate_chain())], False)
   channel_credentials = cygrpc.channel_credentials_ssl(
       resources.test_root_certificates(), None)
   self.server_completion_queue = cygrpc.CompletionQueue()
   self.server = cygrpc.Server()
   self.server.register_completion_queue(self.server_completion_queue)
   self.port = self.server.add_http2_port('[::]:0', server_credentials)
   self.server.start()
   self.client_completion_queue = cygrpc.CompletionQueue()
   client_channel_arguments = cygrpc.ChannelArgs([
       cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override,
                         _SSL_HOST_OVERRIDE)])
   self.client_channel = cygrpc.Channel(
       'localhost:{}'.format(self.port), client_channel_arguments,
       channel_credentials)
Ejemplo n.º 5
0
def ssl_channel_credentials(root_certificates=None, private_key=None, certificate_chain=None):
    """Creates a ChannelCredentials for use with an SSL-enabled Channel.

  Args:
    root_certificates: The PEM-encoded root certificates or unset to ask for
      them to be retrieved from a default location.
    private_key: The PEM-encoded private key to use or unset if no private key
      should be used.
    certificate_chain: The PEM-encoded certificate chain to use or unset if no
      certificate chain should be used.

  Returns:
    A ChannelCredentials for use with an SSL-enabled Channel.
  """
    if private_key is not None or certificate_chain is not None:
        pair = _cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    else:
        pair = None
    return ChannelCredentials(_cygrpc.channel_credentials_ssl(root_certificates, pair))
Ejemplo n.º 6
0
def ssl_channel_credentials(
    root_certificates=None, private_key=None, certificate_chain=None):
  """Creates a ChannelCredentials for use with an SSL-enabled Channel.

  Args:
    root_certificates: The PEM-encoded root certificates or unset to ask for
      them to be retrieved from a default location.
    private_key: The PEM-encoded private key to use or unset if no private key
      should be used.
    certificate_chain: The PEM-encoded certificate chain to use or unset if no
      certificate chain should be used.

  Returns:
    A ChannelCredentials for use with an SSL-enabled Channel.
  """
  if private_key is not None or certificate_chain is not None:
    pair = _cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
  else:
    pair = None
  return ChannelCredentials(
      _cygrpc.channel_credentials_ssl(root_certificates, pair))
Ejemplo n.º 7
0
 def setUp(self):
     server_credentials = cygrpc.server_credentials_ssl(
         None, [
             cygrpc.SslPemKeyCertPair(resources.private_key(),
                                      resources.certificate_chain())
         ], False)
     channel_credentials = cygrpc.channel_credentials_ssl(
         resources.test_root_certificates(), None)
     self.server_completion_queue = cygrpc.CompletionQueue()
     self.server = cygrpc.Server()
     self.server.register_completion_queue(self.server_completion_queue)
     self.port = self.server.add_http2_port('[::]:0', server_credentials)
     self.server.start()
     self.client_completion_queue = cygrpc.CompletionQueue()
     client_channel_arguments = cygrpc.ChannelArgs([
         cygrpc.ChannelArg(cygrpc.ChannelArgKey.ssl_target_name_override,
                           _SSL_HOST_OVERRIDE)
     ])
     self.client_channel = cygrpc.Channel('localhost:{}'.format(self.port),
                                          client_channel_arguments,
                                          channel_credentials)
Ejemplo n.º 8
0
def ssl_channel_credentials(root_certificates=None,
                            private_key=None,
                            certificate_chain=None):
    """Creates a ChannelCredentials for use with an SSL-enabled Channel.

  Args:
    root_certificates: The PEM-encoded root certificates as a byte string,
    or None to retrieve them from a default location chosen by gRPC runtime.
    private_key: The PEM-encoded private key as a byte string, or None if no
    private key should be used.
    certificate_chain: The PEM-encoded certificate chain as a byte string
    to use or or None if no certificate chain should be used.

  Returns:
    A ChannelCredentials for use with an SSL-enabled Channel.
  """
    if private_key is not None or certificate_chain is not None:
        pair = _cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    else:
        pair = None
    return ChannelCredentials(
        _cygrpc.channel_credentials_ssl(root_certificates, pair))
Ejemplo n.º 9
0
def ssl_channel_credentials(root_certificates=None,
                            private_key=None,
                            certificate_chain=None):
    """Creates a ChannelCredentials for use with an SSL-enabled Channel.

  Args:
    root_certificates: The PEM-encoded root certificates as a byte string,
    or None to retrieve them from a default location chosen by gRPC runtime.
    private_key: The PEM-encoded private key as a byte string, or None if no
    private key should be used.
    certificate_chain: The PEM-encoded certificate chain as a byte string
    to use or or None if no certificate chain should be used.

  Returns:
    A ChannelCredentials for use with an SSL-enabled Channel.
  """
    if private_key is not None or certificate_chain is not None:
        pair = _cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    else:
        pair = None
    return ChannelCredentials(
        _cygrpc.channel_credentials_ssl(root_certificates, pair))
Ejemplo n.º 10
0
def channel_credentials_ssl(
    root_certificates, private_key, certificate_chain):
  pair = None
  if private_key is not None or certificate_chain is not None:
    pair = cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
  return cygrpc.channel_credentials_ssl(root_certificates, pair)
Ejemplo n.º 11
0
def channel_credentials_ssl(root_certificates, private_key, certificate_chain):
    pair = None
    if private_key is not None or certificate_chain is not None:
        pair = cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
    return cygrpc.channel_credentials_ssl(root_certificates, pair)