상세 컨텐츠

본문 제목

gerrit 에서 REST 를 사용할 경우 인증 문제 해결 방법

IT : GIT

by 휀스 2014. 7. 26. 14:03

본문



gerrit 에서 REST 를 사용할 경우 인증 문제 해결 방법


gerrit 을 다른 app 나 script 에서 연결할 경우 인증에 대한 문제가 발생하는 경우가 있습니다. http 를 이용한 연결이 아닌 https 를 이용한 연결일 경우 발생하는 문제인데 이를 해결하는 방법은 의외로 간단합니다.



일반적인 gerrit 의 REST 연결은 아래와 같이 userid 와 httppasswd 만으로 연결 가능합니다.


$ curl --digest  --user userid:httppasswd -X GET http://gerrit.gerritserver.com:8000/projects/ProjectName/config


하지만 https 일 경우는 이런 command 를 사용하면 아래와 같은 error를 return 하게 됩니다.


$ curl --digest  --user userid:httppasswd -X GET https://gerrit.gerritserver.com:8000/projects/ProjectName/config


curl: (60) SSL certificate problem: self signed certificate

More details here: http://curl.haxx.se/docs/sslcerts.html


curl performs SSL certificate verification by default, using a "bundle"

 of Certificate Authority (CA) public keys (CA certs). If the default

 bundle file isn't adequate, you can specify an alternate file

 using the --cacert option.

If this HTTPS server uses a certificate signed by a CA represented in

 the bundle, the certificate verification probably failed due to a

 problem with the certificate (it might be expired, or the name might

 not match the domain name in the URL).

If you'd like to turn off curl's verification of the certificate, use

 the -k (or --insecure) option.


이런 경우 해결 방법은 의외로 간단합니다. Error 문구에 씌여 있는 대로 -k 옵션을 사용하기만 하면 됩니다.


$ curl -k --digest  --user userid:httppasswd -X GET https://gerrit.gerritserver.com:8000/projects/ProjectName/config

Not found



그러면 에러 문구가 또 바뀌어 나옵니다. 


Not found


이럴 때 해결하는 방법은?? gerrit 의 REST Documents 에 보면 해결 방법이 나와 있습니다. URL 에 /a/ 를 넣어주면 됩니다.


$ curl  -k --digest  --user userid:httppasswd -X GET https://gerrit.gerritserver.com:8000/a/projects/ProjectName/config


)]}'

{

  "kind": "gerritcodereview#project_config",

  "description": "Rights of test Project",

  "use_contributor_agreements": {

    "value": false,

    "configured_value": "INHERIT",

    "inherited_value": false

  },

.......

.......

.......

  "max_object_size_limit": {},

  "submit_type": "MERGE_IF_NECESSARY",

  "actions": {},

  "commentlinks": {}

}


이방법을 응용하면 https 환경에서 REST 를 이용한 gerrit 사용을 할 수 있습니다.



관련글 더보기