Skip to content

Commit

Permalink
events
Browse files Browse the repository at this point in the history
  • Loading branch information
hazae41 committed Nov 15, 2023
1 parent 7e48375 commit 0e685e5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mods/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface TlsClientDuplexParams {
}

export type TlsClientDuplexReadEvents = CloseEvents & ErrorEvents & {
certificates: (certificates: X509.Certificate[]) => Result<void, Error>
handshaked: () => void
}

Expand Down Expand Up @@ -414,6 +415,14 @@ export class TlsClientDuplex {
const server_certificates = certificate.certificate_list.value.array
.map(it => X509.tryReadAndResolveFromBytes(X509.Certificate, it.value.bytes).throw(t))

const handled = await this.events.input.emit("certificates", [server_certificates])

if (handled.isSome()) {
handled.get().throw(t)
this.#state = { ...state, action: "server_certificate", server_certificates }
return Ok.void()
}

const now = new Date()

if (server_certificates.length === 0)
Expand Down

0 comments on commit 0e685e5

Please sign in to comment.