본문 바로가기

[IT/Programming]/HTML related

Vert.x 로 https (SSL/TLS) server 만들기

# Vert.x 로 https (SSL/TLS) server 만들기 Vertx 로 secure server 인 https (SSL/TLS) server 를 만들어 봅시다. ## TOC ## keytool .jks 우선 RSA key 를 만들어 줘야 하는데... 명령어는 다음과 같다. 윈도우 cmd 에서 다음과 같은 명령어를 입력하자. ```[.linenums] C:\Recoeve> keytool -genkeypair -alias recoeve.net -keyalg RSA -keysize 2048 -keystore recoeve.jks -validity 3650 // 실행하면 다음과 같이 뜸. Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: KANGSOO LEE What is the name of your organizational unit? [Unknown]: Recoeve.net What is the name of your organization? [Unknown]: Recoeve.net What is the name of your City or Locality? [Unknown]: Korea What is the name of your State or Province? [Unknown]: Korea What is the two-letter country code for this unit? [Unknown]: KR Is CN=KANGSOO LEE, OU=Recoeve.net, O=Recoeve.net, L=Korea, ST=Korea, C=KR correct? [no]: yes Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 3,650 days for: CN=KANGSOO LEE, OU=Recoeve.net, O=Recoeve.net, L=Korea, ST=Korea, C=KR ```/ ## Default port of HTTPS is 443. 이것땜에 좀 고생을 했는데, https 접속은 port 443 으로 자동으로 연결된다. 이를 모르고 port 80 에 listen 걸어놓고, https://localhost 로 접속하면 응답이 없게됨. ```[.linenums.lang-java] import io.vertx.core.AbstractVerticle; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.http.HttpServerRequest; import io.vertx.core.net.JksOptions; import io.vertx.ext.web.Router; public class Recoeve extends AbstractVerticle { @Override public void start() { Router router=Router.router(vertx); router.route().handler(ctx -> { HttpServerRequest req=ctx.request(); System.out.println("A client has connected!"); req.response().putHeader("Content-Type","text/plain; charset=utf-8"); req.response().end("Hello World!", "UTF-8"); }); vertx.createHttpServer( new HttpServerOptions() .setUseAlpn(true) .setSsl(true) .setKeyStoreOptions(new JksOptions() .setPath("C:/Recoeve/recoeve.jks") .setPassword("[--password--]") ) ).requestHandler(router).listen(443); } // public void start() } // public class Recoeve extends AbstractVerticle ```/ ## EC2 - Security Groups - AWS Inbound rules AWS Inbound rules 에서 HTTPS TCP port 443 을 열어줘야 함. ## Windows firewall Server 의 Windows firewall 설정에서도 port 443 을 열어줘야 함. Inbound, Outbound 둘 다. ## RRA
  1. stackoverflow.com :: vertx HTTPS (SSL/TLS) server does not work. I cannot access https://localhost, asked at 2019-03-30, by kipid
  2. vertx.io/docs/vertx-core/java :: Configuring an HTTP/2 server (TLS)
  3. kipid's blog :: Learning Vert.x

태그