ponsim_olt.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:voltha 作者: opencord 项目源码 文件源码
def get_channel(self):
        if self.channel is None:
            device = self.adapter_agent.get_device(self.device_id)

            # read in certificate
            try:
               with open('/voltha/pki/voltha-CA.pem') as f:
                  trusted_certs = f.read()

               with open('/voltha/pki/voltha.crt') as f:
                  client_cert = f.read()

               with open('/voltha/pki/voltha.key') as f:
                  client_key = f.read()
            except Exception as e:
               log.error('failed-to-read-cert-keys', reason=e)

            # create credentials
            credentials = grpc.ssl_channel_credentials( root_certificates=trusted_certs, private_key=client_key, certificate_chain=client_cert)

            # create channel using ssl credentials
            my_server_host_override_string = "ABCD" # Server's CN Name, Ugly but no other Choice.
            self.channel = grpc.secure_channel(device.host_and_port, credentials, options=(('grpc.ssl_target_name_override', my_server_host_override_string,),))

        return self.channel
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号