Skip to content

get_min_proto_version and get_max_proto_version cannot be called on a val SSLContext #75

Description

@SeanTAllen

SSLContext.get_min_proto_version and SSLContext.get_max_proto_version are declared fun ref. Neither mutates anything. Both read _ctx and hand it to SSL_CTX_ctrl with a get command.

SSLContext is class val, and the pattern the library itself demonstrates is to configure a context and then hold it as val. examples/ssl-client-server-example/ssl-client-server-example.pony declares let _sslctx: SSLContext, which is val, and only ever calls client and server on it. A val context cannot call either getter:

receiver type is not a subtype of target type
    let v = ctx.get_min_proto_version()
    receiver type: SSLContext val
    target type: SSLContext ref^
    SSLContext val is not a subtype of SSLContext ref^: val is not a subcap of ref^

So two public, documented, tested methods cannot be called on the context shape a caller following the example holds.

Fix direction

fun ref becomes fun box on both getters. That is additive: box accepts every receiver ref accepts and adds val and box. Existing ref callers keep working, the null guard still compiles, and the test suite still passes.

The setters are correctly fun ref. They change the context's protocol bounds through the C pointer, and a val context should not be able to call them. Only the getters have the wrong capability, and they most likely got it by being written next to the setters.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions