Skip to content

Commit c714433

Browse files
committed
Fail when attempting to start an H2 server without SSL context and h2c disabled
1 parent d0ea958 commit c714433

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/aleph/http/server.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@
732732
http-versions
733733
ssl-context
734734
manual-ssl?
735+
use-h2c?
735736
shutdown-executor?
736737
epoll?
737738
transport
@@ -757,6 +758,12 @@
757758
:ssl? (or manual-ssl? (boolean ssl-context))
758759
:http1-pipeline-transform http1-pipeline-transform
759760
:continue-executor continue-executor))]
761+
762+
(when (and (not ssl-context)
763+
(not use-h2c?)
764+
(some #{:http2} http-versions))
765+
(throw (IllegalArgumentException. "HTTP/2 requires ssl-context to be given or use-h2c? to be true.")))
766+
760767
(netty/start-server
761768
{:pipeline-builder pipeline-builder
762769
:bootstrap-transform bootstrap-transform

test/aleph/http_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,8 +1403,8 @@
14031403
(testing "HTTP/2 without ssl-context"
14041404
(let [result (try-start-server
14051405
{:http-versions [:http2]})]
1406-
;; TODO: Shouldn't this fail?
1407-
(is (= :started result))))
1406+
(is (instance? IllegalArgumentException result))
1407+
(is (= "HTTP/2 requires ssl-context to be given or use-h2c? to be true." (ex-message result)))))
14081408
(testing "HTTP/2 without ssl-context but with h2c"
14091409
(let [result (try-start-server
14101410
{:use-h2c? true

0 commit comments

Comments
 (0)