我有一个用Python编写的GRPc服务器,我刚刚实现了TSL加密。
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
test_pb2_grpc.add_TestServicer_to_server(TestServicer(), server)
with open(SERVER_PRIVATE_KEY, 'rb') as f:
private_key = f.read()
with open(SERVER_CERTIFICATE, 'rb') as f2:
certificate_chain = f2.read()
server_credentials = grpc.ssl_server_credentials(((private_key, certificate_chain,),))
server.add_secure_port('[::]:{}'.format(SERVER_PORT), server_credentials)
server.start()
如果我尝试不使用证书进行连接
with grpc.insecure_channel(target='localhost:50051') as channel:
stub = test_pb2_grpc.TestStub(channel)
guide_get_one_feature(stub, Test_pb2.UserInfo("test"))
我在服务器上收到此错误
E0712 14:30:29.748944000 123145353949184 ssl_transport_security.cc:1238] Handshake failed with fatal error SSL_ERROR_SSL: error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER.
我已经设置了记录器以写入文件
logger = logging.getLogger(name)
filename = datetime.datetime.now().strftime("%Y-%m-%d")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.FileHandler("{}.log".format(filename)))
但是我无法记录到grpc错误。有办法解决这些错误吗?