2017-12-05 3 views
1

클라이언트와 서버간에 tls/ssl 연결을 만들고 싶습니다 (상호간, 편도가 아님). gRPC : TLS/SSL 작동을 위해 certificateChainFile 및 privateKeyFile 생성

내 설정이다 :

서버 :

Server server = ServerBuilder.forPort(8443) 
     // Enable TLS 
     .useTransportSecurity(certChainFile, privateKeyFile) 
     .addService(new GreetingServiceImpl()) 
     .build(); 

클라이언트

// With server authentication SSL/TLS 
    ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8443) 
     .build(); 
    GreetingServiceGrpc.GreetingServiceBlockingStub stub = 
      GreetingServiceGrpc.newBlockingStub(channel); 

내가 필요로하는 모든 터미널 를 생성하는 명령 .PEM에 certChainFileprivateKeyFile (이다)이 파일을 serv에 전달합니다. er 코드를 사용하십시오.

답변

0

내가 필요로하는 모든 터미널이다는 certChainFile 및 privateKeyFile

openssl req -x509 -newkey rsa:1024 -keyout ./testkey.pem -out ./testcert.crt -days 999 -subj "/CN=localhost" 

이 명령은이 RSA 키와 자체 서명 된 인증서 생성 생성하는 명령.

하지만 그 이상이 필요합니다.

  1. SSL은 기본적으로 일반 이름 (CN)이 호스트 이름과 같은지 확인합니다. 따라서 CN = localhost

  2. 클라이언트가 서버의 인증서를 신뢰해야하므로 인증서를 생성해야합니다. 인증서를 클라이언트의 trustore로 가져와야합니다 (그러나 클라이언트의 신뢰 저장소를 구성하는 방법을 모르지만). 의뢰인, 나는 너에게 맡길 것이다).

관련 문제