HTTPS를 위한 공인인증서 - Let's Encrypt 발급

2020-06-02: 매뉴얼 방식 수정

2020-02-02: 최초 작성
{:.right-history}

Nginx 서버에서 HTTPS 사용할 수 있는 공인인증서를 발급해 설치하려고 한다.

  • 여기서는 Lets Encrypt 무료 공인인증서 발급을 다룬다.
  • letsecrypt 공인인증서는 3개월 정도 기간만 사용 가능하고 갱신해야 한다.
  • **단독 도메인을 호스팅하는 개인 서버에서 Nginx**에 적용해 본다.

인증서는 개별 도메인 혹은 와일드카드 인증서 로 도메인 안의 모든 호스트를 포함하는 두 종류로 발급이 가능하다.

자세히 보기
:
An Architectural Style for Distributed Hypermedia Interaction”

REST 2000

Roy T. Fielding, 박사 논문으로 발표

“Architectural Styles and the Design of Network-based Software Architectures”

이 기술의 근간은 Web API 이다.


SOAP

Micsoft에서도 XML-RPC 1998를 통해 Web API를 구현하고자 했다.

Microsoft, SOAP

Salesforce API

Salesforce API, 2000 은 이런 방식을 처음 도입했다.
https://web.archive.org/web/20001018092215/http://salesforce.com/

flickr API

flickr의 SOAP

https://web.archive.org/web/20040921173223/http://www.flickr.com:80/services/api/response.soap.html

flickr의 REST API

https://web.archive.org/web/20040821031039/http://www.flickr.com:80/services/api/response.rest.html

SOAP과 REST
SOAP REST
- 복잡하다 - 단순하다
- 규칙 많음 - 규칙 적다
- 어렵다 - 쉽다

Google trends 검색

2006년, AWS가 자사 API의 85%를 REST로 구현
2010년, Salesforce.com에서 REST API 추가

CMIS

2008년 CMIS 표준 준비

그러나 Roy T. Fielding: “No REST in CMIS”

REST API guideline

2016년 Microsft 가 제시한 REST API Guideline

Roy T. Fielding:
“s/REST API/HTTP API/“

http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven

그리고

“REST API를 위한 최고의 버저닝 전략은 버저닝을 안 하는 것”

결국 REST API는

REST 를 구성하는 스타일

아키텍쳐 스타일 은 다음 같이 구성된다:

Uniform interface

Uniform Interface

Self descriptive message

Self-descriptive message, 메시지는 스스로를 설명해야한다

1
GET / HTTP/1.1

이 HTTP 요청 메시지는 뭔가 빠져있어서 self-descriptive 하지 못하다.

목적지를 추가하면 이제 self-descriptive

1
2
GET / HTTP/1.1
Host: www.example.org

결과 메시지도

1
2
3
HTTP/1.1 200 OK

[ { "op": "remove", "path": "/a/b/c" } ]
1
2
3
4
HTTP/1.1 200 OK
Content-Type: application/json-patch+json

[ { "op": "remove", "path": "/a/b/c" } ]
HATEOAS

애플리케이션의 상태는 Hyperlink를 이용해 전이되어야한다.
http://slides.com/eungjun/rest#/37

독립성

서버와 클라이언트가 각각 독립적으로 진화한다.
서버의 기능이 변경되어도 클라이언트를 업데이트할 필요가 없다.
REST를 만들게 된 계기: “How do I improve HTTP without breaking the Web.”

호환성 유지

HTML5 첫 초안에서 권고안 나오는데까지 6년

HTTP/1.1 명세 개정판 작업하는데 7년

상호운용성에 대한 집착

Referer 오타지만 안 고침

Referer의 개념을 Tim Berners Lee에게 제안한 것은 Phillip M. Hallam-Baker 이지만, 이름까지 정해서 주지는 않았다고 한다. 따라서 오타를 만든 것은 Tim Berners Lee인 것으로 추정하는듯.

See https://lists.w3.org/Archives/Public/ietf-http-wg-old/1995JanApr/0109.htm

charset 잘못 지은 이름이지만 안 고침

charset은 “character set”이 아님에도 불구하고 그런 오해를 계속해서 불러일으키고 있다.

http://w3-org.9356.n7.nabble.com/How-to-pronounce-quot-charset-quot-td254585.html#message254629

HTTP 상태 코드 418 포기함 (I’m a teapot)

https://www.facebook.com/eungjun/posts/10213901564392694

HTTP/0.9 아직도 지원함 (크롬, 파이어폭스)

구글 크롬에서 HTTP/0.9 지원을 완전히 제거하려다 실패했다. Tenda D301 router와의 호환성이 깨지는 문제가 발견되어서. default port인 경우에만 HTTP/0.9를 지원하도록 하려고 했는데 그마저도 문제가 발견되어 revert했다:
https://bugs.chromium.org/p/chromium/issues/detail?id=624462

REST가 웹의 독립적 진화에 도움을 주었나

그럼 REST는 성공했는가

그런데 REST API는?
REST API는 REST 아키텍쳐 스타일을 따라야한다.
오늘날 스스로 REST API라고 하는 API들의 대부분이 REST 아키텍쳐 스타일을 따르지 않는다.

REST 스타일 가이드를 따랴야 한다.링크

An API that provides network-based access to resources via a uniform interface of self-descriptive messages containing hypertext to indicate potential state transitions might be part of an overall system that is a RESTful application
– Roy T. Fielding

구현이 쉽지는 않다.

원격 API가 REST API여야 하나?

시스템 전체를 통제할 수 있다고 생각하거나, 진화에 관심이 없다면, REST에 대해 따지느라 시간을 낭비하지 마라

링크

REST emphasizes evolvability to sustain an uncontrollable system. If you think you have control over the system or aren’t interested in evolvability, don’t waste your time arguing about REST.
– Roy T. Fielding

현재는

(1) REST API를 구현하고 REST API라고 부른다.
(2) REST API 구현을 포기하고 HTTP API라고 부른다.
(3) REST API가 아니지만 REST API라고 부른다. (현재 상태)

그러므로 제약 조건을 따르던지 다른 단어를 써라!!!

I am getting frustrated by the number of people calling any HTTP-based interface a REST API. … Please try to adhere to them or choose some other buzzword for your API.
– Roy T. Fielding

일반 Web과 REST API 비교

http://slides.com/eungjun/rest#/63

open api spec

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

[Open API] Alading Bookstore Open API

Aladin Open API

키 인증 방식으로 일반 1일 호출 5000회 가능하다.

http://blog.aladin.co.kr/openapi/category/29154404?communitytype=MyPaper

TTB 가입 방법

여기 http://www.aladdin.co.kr/ttb/wjoinus.aspx 에서 TTB 가입한다. 승인 완료되면 TTB Key값이 발급된다.

TTB Key값은 http://www.aladin.co.kr/ttb/wblog_manage.aspx 이 페이지에서 조회하실 수 있습니다. 이 키값은 OPENAPI 키값으로 사용됩니다.

상품 API

여기 http://blog.aladin.co.kr/openapi/category/29154402?communitytype=MyPaper 설명되어 있다.

  • 제공 리스트 종류
  • 신간 전체 리스트
  • 주목한 만한 신간 리스트
  • 편집자 추천 리스트(카테고리로만 조회 가능 - 국내도서/음반/외서 만 지원)
  • 베스트셀러
  • 북플 베스트셀러(국내도서 만 조회 가능)

요청 URL : http://www.aladin.co.kr/ttb/api/ItemList.aspx

요청 URL샘플 :

1
http://www.aladin.co.kr/ttb/api/ItemList.aspx?ttbkey=TTBKey&QueryType=ItemNewAll&MaxResults=10&start=1&SearchTarget=Book&output=xml&Version=20131101

상품 json 형식

item array 밑에 결과 데이터가 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{
"version": "20131101",
"logo": "http://image.aladin.co.kr/img/header/2011/aladin_logo_new.gif",
"title": "알라딘 베스트셀러 리스트 - 소설/시/희곡",
"link": "http://www.aladin.co.kr/shop/common/wbest.aspx?BestType=Bestseller&BranchType=1&CID=1&Year=2013&Month=11&Week=1&partner=openAPI",
"pubDate": "Tue, 05 Nov 2013 07:48:18 GMT",
"totalResults": 200,
"startIndex": 1,
"itemsPerPage": 10,
"query": "QueryType=BESTSELLER;CategoryId=1;Year=2013;Month=11;Week=1",
"searchCategoryId": 1,
"searchCategoryName": "소설/시/희곡",
"item": [
{
"title": "제3인류 1",
"link": "http://www.aladin.co.kr/shop/wproduct.aspx?ISBN=8932916373&partner=openAPI",
"author": "베르나르 베르베르 지음, 이세욱 옮김",
"pubDate": "2013-10-21",
"description": "베르나르 베르베르 특유의 상상력으로 축조한 장대한 스케일의 과학 소설. 남극. 저명한 고생물학자 샤를 웰즈의 탐사대가 17미터에 달하는 거인의 유골들을 발굴한다. 그러나 인류사를 다시 쓰게 만들 이 중대한 발견은 발굴 현장의 사고와 함께 곧바로 파묻히고 마는데…",
"isbn": "8932916373",
"isbn13": "9788932916378",
"itemId": 32136853,
"priceSales": 12420,
"priceStandard": 13800,
"mallType": "BOOK",
"stockStatus": "",
"mileage": 1250,
"cover": "http://image.aladin.co.kr/product/3213/68/coversum/8932916373_2.jpg",
"publisher": "열린책들",
"salesPoint": 72420,
"fixedPrice": true,
"customerReviewRank": 9,
"bestRank": 1,
"subInfo": {
"ebookList": [
{
"itemId": 32241318,
"isbn": "E893291637",
"priceSales": 8100,
"link": "http://www.aladin.co.kr/shop/wproduct.aspx?ISBN=E893291637&partner=openAPI"
}
],
"usedList": {
"aladinUsed": {
"itemCount": 0,
"minPrice": 0,
"link": "http://www.aladin.co.kr/shop/UsedShop/wuseditemall.aspx?ISBN=8932916373&TabType=2&partner=openAPI"
},
"userUsed": {
"itemCount": 9,
"minPrice": 8900,
"link": "http://www.aladin.co.kr/shop/UsedShop/wuseditemall.aspx?ISBN=8932916373&TabType=1&partner=openAPI"
}
}
}
},
{
"title": "제3인류 2",
"link": "http://www.aladin.co.kr/shop/wproduct.aspx?ISBN=8932916381&partner=openAPI",
"author": "베르나르 베르베르 지음, 이세욱 옮김",
"pubDate": "2013-10-21",
"description": "베르나르 베르베르 특유의 상상력으로 축조한 장대한 스케일의 과학 소설. 남극. 저명한 고생물학자 샤를 웰즈의 탐사대가 17미터에 달하는 거인의 유골들을 발굴한다. 그러나 인류사를 다시 쓰게 만들 이 중대한 발견은 발굴 현장의 사고와 함께 곧바로 파묻히고 마는데…",
"isbn": "8932916381",
"isbn13": "9788932916385",
"itemId": 32136901,
"priceSales": 12420,
"priceStandard": 13800,
"mallType": "BOOK",
"stockStatus": "",
"mileage": 1250,
"cover": "http://image.aladin.co.kr/product/3213/69/coversum/8932916381_2.jpg",
"publisher": "열린책들",
"salesPoint": 50880,
"fixedPrice": true,
"customerReviewRank": 10,
"bestRank": 2,
"subInfo": {
"ebookList": [
{
"itemId": 32241317,
"isbn": "E893291638",
"priceSales": 8100,
"link": "http://www.aladin.co.kr/shop/wproduct.aspx?ISBN=E893291638&partner=openAPI"
}
],
"usedList": {
"aladinUsed": {
"itemCount": 0,
"minPrice": 0,
"link": "http://www.aladin.co.kr/shop/UsedShop/wuseditemall.aspx?ISBN=8932916381&TabType=2&partner=openAPI"
},
"userUsed": {
"itemCount": 3,
"minPrice": 10500,
"link": "http://www.aladin.co.kr/shop/UsedShop/wuseditemall.aspx?ISBN=8932916381&TabType=1&partner=openAPI"
}
}
}
}
]
}