2015년 11월 27일 금요일

인증서를 포함한 proxy 서버 내에서의 빌드

2015. 11. 19.

Intellij(IDE)로 gradle(or maven) project import 하는데

프로젝트 에러가 남!!

r1> 메모리 부족

a> 여유 메모리를 만들고 나니 다음 스텝으로 이동
 또는 실행설정에 메모리설정을 해줘도 된다고 함.
 (gradle의 경우 여유 메모리가 적을 경우 빌드 시에 에러 발생)


r2> connection 이 안된다. (Connection Failed)

a> 사용자/.m/settings.xml 에 proxy 설정
  <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>(Proxy서버)</host>
      <port>(Proxy서버 포트)</port>
      <username></username>
      <password></password>
      <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
    </proxy>
  </proxies>


a> gradle 설정파일에 http, https proxy를 설정해줘야 한다!!
systemProp.http.proxyHost=(Proxy서버)
systemProp.http.proxyPort=(Proxy서버 포트)
systemProp.http.proxyUser=
systemProp.http.proxyPassword=
systemProp.http.nonProxyHosts=localhost


r3> https 인증 오류

 https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.3.0.RELEASE/spring-boot-gradle-plugin-1.3.0.RELEASE.pom


 Could not GET 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.3.0.RELEASE/spring-boot-gradle-plugin-1.3.0.RELEASE.pom.
     > peer not authenticated
여기서 받아와야 하는데,.두둥...
SSL 인증오류가 난다!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(https가 아니라 http로 repository를 변경할 수 있는 건 변경해서 쓰면 해결!)
(내부적으로 설정된 https 주소로 접속한다면............. 아래로 더 내려가보자)

a>

you need to import certificate :

open the 'https://some_server.com/some/path/some.pom' in your favorite browser
export the cert using the Steps to export cert from a web site
copy the cer into JDK_HOME/jre/lib/security folder
open a shell and go to  JDK_HOME/jre/lib/security folder
then import the cer into java using the

cmd창에 입력(원문은 import였는데 해당 명령이 없어서 importcert로 변경해서 씀)
keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit


keytool -importcert -alias internal_cert -file AAA.cer -keystore cacerts -storepass changeit


--> 내가 속해있는 곳의 네트워크망이 인증서를 가지고 있었다. 그 인증서 파일을 위와 같은 방법으로 저장을 해주면, java를 통한 https 통신을 할 때 자동으로 사용하게 된다. 


(추가설명)
  keytool은 java tool로서, java를 시스템 path에 설정해 놓은 경우 실행 가능하다. 당연히 keytool로 명령을 실행하면 시스템 path에 설정한 java에 인증서를 등록한 것이다.
  그러므로, 이 설정이 통하려면 IDE, Gradle 또는 Maven 작업 시에 사용되는 jdk가 시스템 path에 잡힌 java와 동일해야 한다.



***
2015.12.04 추가 읽어볼 자료.
https, ssl 인증에 대한 내용.

https://opentutorials.org/course/228/4894

guova

Lists.newArrayList();