Skip to content

Failure to initialise Netty channel when using :manual-ssl? #751

Open
@scramjet

Description

@scramjet

[aleph "0.8.3"], Java 17, macOS 15.4

Hello,

I'm using the :manual-ssl? option in http/start-server (in fact I actually added that option as a PR some years ago), so I can do my own custom SNI set up for TLS.

Updating to 0.8.3 from 0.6.0, I get the following exception:

Failed to initialize a channel. Closing: [id: 0xc0aa1062, L:/[0:0:0:0:0:0:0:1]:30001 - R:/[0:0:0:0:0:0:0:1]:60187]: java.lang.NullPointerException: Cannot invoke "io.netty.handler.ssl.SslContext.newHandler(io.netty.buffer.ByteBufAllocator)" because "ssl_ctx" is null
java.lang.NullPointerException: Cannot invoke "io.netty.handler.ssl.SslContext.newHandler(io.netty.buffer.ByteBufAllocator)" because "ssl_ctx" is null
	at aleph.netty$ssl_handler.invokeStatic(netty.clj:1502)
	at aleph.netty$ssl_handler.invoke(netty.clj:1488)
	at aleph.http.server$make_pipeline_builder$pipeline_builder_STAR___72092.invoke(NO_SOURCE_FILE:645)
	at aleph.netty$add_channel_tracker_handler$fn__51328.invoke(netty.clj:1668)
	at aleph.netty$pipeline_initializer$fn__51142.invoke(netty.clj:826)
	at aleph.http.AlephChannelInitializer.initChannel(AlephChannelInitializer.java:17)

At aleph.http.server:644 (make-pipeline-builder) there is:

(cond ssl?
            (let [ssl-handler (netty/ssl-handler (.channel pipeline) ssl-context)]
              (log/debug "Setting up secure HTTP server pipeline.")
              (log/debug "ALPN HTTP versions:" (mapv str (.nextProtocols ssl-context)))
…

ssl? is set to true in the server init logic if there is an ssl-context option or manual-ssl? is set. In this case, there is no context (it'll be added by a pipeline transform later). Changing that cond line to (cond (and ssl? ssl-context) …) seems to be the fix here.

Cheers,

Matt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions