2017-06-23 3 views
0

私はsoftwareprojectに取り組んでいます。私はProxiを作るという仕事をしています。このClientproxiはwin10 上でJavaで実行され、組み込みServiceregistry Yocto-Linuxと通信し、certivicateexchange TLS1.2でHTTP経由で安全な外部接続を構築する必要があります。イム道具とbouncycastlelibrariesと協力し、次が行っている:"openTlsConnect" CAとopenTlsConnectの認証

UnsecureHttpExecutor unsecureHttpExecutor = new UnsecureHttpExecutor();// Connection for external Clientservices 
    logger.debug("Try to connect!"); 
    HttpRequest httpRequest = new BasicHttpRequest("GET", "/auth");// simple GET /auth -for REST 
    logger.debug("http.request: \n" + httpRequest.toString()); 


    try { 
     HttpResponse httpResponse = unsecureHttpExecutor.executeRequest(httpRequest);// createHttpClient(); connectHttpClient(); 
     String mibIdentifierJson = EntityUtils.toString(httpResponse.getEntity()); 
     logger.debug("This is MIBIdentifierJson:\n" + mibIdentifierJson); 
     ResponseObject responseObject = JsonUtils.objectMapper().readValue(mibIdentifierJson, ResponseObject.class); 
     logger.debug("JSONUtils" + JsonUtils.objectMapper().readValue(mibIdentifierJson, ResponseObject.class).toString()); 



     ClientContext clientContext = null; 
     RegistrationProcess registrationProcess = new RegistrationProcess(); 
     logger.debug("Here is all ok!?"); 
     RegistrationResult registrationResult = registrationProcess.registerNewClient(); //<-- Here are the question   

//__________________________________________________________________________ 

public RegistrationResult registerNewClient(ClientContext clientContext) { 
     RegistrationResult registrationResult = null; 

     try { 

      createHttpClient(); 

      // create KeyPair, CSR and Self-Signed certificate which will be send to server during tls handshake (see MSC_002) 
      KeyPair keyPair = CertificateUtils.generateKeyPair(); 
      //L.d("KeyPair abgeschlossen"); 
      logger.debug("KeyPair abgeschlossen KeyPair: " + keyPair.toString()); 
      PKCS10CertificationRequest certificationRequest = CertificateUtils.createCertificationRequest(/*clientContext.getAppName()*/"Testapp", keyPair); 
      logger.debug("PKCS10CertificationRequest erfolgreich abgeschlossen"); 
      //L.d("PKCS10CertificationRequest erfolgreich abgeschlossen" 
      X509CertificateHolder selfSignedCertificate = CertificateUtils.selfSignCertificate(certificationRequest, keyPair.getPrivate()); 
      //L.d("X509 Selbstsigniertes"); 

      logger.debug("X509 Selbstsigniertes Certifikat erstellt" + selfSignedCertificate.toString()); 
      openTlsConnect(selfSignedCertificate, keyPair.getPrivate()); 

を私は、ログ

08:30:15.264 [main] DEBUG [main][connect()] - Try to connect!                
08:30:15.268 [main] DEBUG [main][connect()] - http.request:                GET /auth []                             
08:30:15.296 [main] DEBUG [main][connect()] - Das ist der MIBIdentifierJson:           {"data":[{"id":"","name":"this is the auth-service of ViWi-ServiceRegistry","uri":"auth\/"}],"status":"ok","timestamp":1002380}                              
08:30:15.401 [main] DEBUG [main][connect()] - [email protected]         
08:30:15.402 [main] DEBUG [main][connect()] - Hier noch alles gut!               
08:30:15.598 [main] DEBUG [Registrationprocess] - KeyPair abgeschlossen KeyPair: [email protected] 
08:30:15.619 [main] DEBUG [Registrationprocess] - PKCS10CertificationRequest erfolgreich abgeschlossen     
08:30:15.626 [main] DEBUG [Registrationprocess] - X509 Selbstsigniertes Certifikat [email protected]                         Registration started                         RegistrationSocked erstellt                        
08:30:15.627 [main] DEBUG Registrationsocked] - Connect registration socket using timeout: 3000 
08:30:15.638 [main] DEBUG Registrationsocked] - Client Inputstream: %s                                           
08:30:15.638 [main] DEBUG Registrationsocked] - Client Outputstream: %s                                           
08:30:15.639 [main] DEBUG Registrationsocked] - TlsClientProtocol              
08:30:15.639 [main] DEBUG Registrationsocked] - connect now via tls              
08:30:15.639 [main] DEBUG Registrationsocked] - TLS Client:                [email protected]                    
08:30:15.639 [main] DEBUG Registrationsocked] - TLS Client:                [email protected]                   java.io.IOException: Internal TLS error, this could be an attackCould not perform registration process. 

次のような問題は、メソッドopenTLSConnectionに産む取得し、私は私が間違って行って何を知りません。 TLS接続またはクライアント接続を取得する別の方法があるかもしれません。コメントはthx foward!

+0

私はdebbugedを持っており、システムに私にこのバグが表示されます – Paul

答えて

0

コードは正しくありましたが、ポート443にする必要があります。

関連する問題