Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIO server HTTPS support on Native #2942

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

olme04
Copy link
Contributor

@olme04 olme04 commented Apr 12, 2022

Based on: #2939

Subsystem
Server, CIO

Motivation
Fixes https://youtrack.jetbrains.com/issue/KTOR-694 for native

Solution

  • New backward-compatible API for multiplatform SSL connectors (similar to TLSConfig from ktor-network-tls)
  • CIO HTTPS support on native
  • Make current JVM engines support both old and new configuration

TODO:

  • looks like it will better to deprecate current APIs, and remove them with next MAJOR release
  • Tests with client certificate verification is now disabled at all: looks like it's possible to create one more SSL connector in EngineTestBase to test also for it

if (result.status == SSLEngineResult.Status.CLOSED) break@loop
}
}
} catch (cause: Throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionCaught: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

(at-me in a reply with help or ignore)

if (unwrapDestination !== initialUnwrapDestination) updateUnwrapDestination(unwrapDestination)
resumeUnwrapContinuation(result)
return result
} catch (cause: Throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionCaught: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

(at-me in a reply with help or ignore)

}

return result
} catch (cause: Throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionCaught: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

(at-me in a reply with help or ignore)

"Failed to parse PKCS12 file"
}
return PKCS12Certificate(privateKey.value!!, x509Certificate.value!!)
} catch (cause: Throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionCaught: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

(at-me in a reply with help or ignore)

}
//println("[$debugString] WRITING STEP RESULT: $result")
} while (result > 0)
} catch (cause: Throwable) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionCaught: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

(at-me in a reply with help or ignore)

connectionIdleTimeoutSeconds = connectionIdleTimeoutSeconds
)
internal actual fun TLSConfigBuilder.takeFromConnector(connectorConfig: EngineSSLConnectorConfig) {
connectorConfig.authentication?.let { config ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a?b.let { b -> b?.clet { c -> ... }

is hard to read. Could be replaced with:

val c = a?.b?.c

instead

keyAlias: String,
keyStorePassword: () -> CharArray,
privateKeyPassword: () -> CharArray
) : this() {
Copy link
Member

@e5l e5l May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also can make this constructor primary(with all val parameters) and make the actual constructor secondary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants