https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • x

    Xevion

    02/21/2023, 8:21 AM
    I thought so too
  • x

    Xevion

    02/21/2023, 8:22 AM
    Switching to a completely synchronous flow fixed it, and it's not that slow, so it's not a big deal.
  • x

    Xevion

    02/21/2023, 8:22 AM
    Just feels like Workers has so many little weird issues I keep hitting.
  • k

    kian

    02/21/2023, 8:28 AM
    Probably worth posting in #940663374377783388 - I can't see that error in the runtime so likely thrown from something else in the stack
  • u

    0xblackbird

    02/21/2023, 12:52 PM
    Hi, I've got a worker that needs to send https requests to a backend api server with an invalid ssl certificate (invalid certificate authority). I've looked at #1052656806058528849 and someone had a quite similar case where he/she made use of
    NODE_EXTRA_CA_CERTS
    env variable. I tried this as well but that didn't help either. I really want to refrain from turning of ssl validation (using
    NODE_TLS_REJECT_UNAUTHORIZED
    )
  • u

    0xblackbird

    02/21/2023, 12:55 PM
    Is there perhaps any way to make this work? Feel free to let me know if you need me to provide any code or so (I'm using the fetch api to send the request)
  • k

    kian

    02/21/2023, 1:06 PM
    I'm not aware of anything in Workers that'd let you fetch HTTPS when it has an invalid certificate
  • u

    0xblackbird

    02/21/2023, 1:12 PM
    Thanks! In that case I'll look at other options, I spent days trying to get a valid certificate for that server but nothing worked yet, even the provider couldn't help me fix it so far
  • p

    Ping for toast

    02/21/2023, 2:12 PM
    Is there some way to generate a secret for workers serverside? For instance
    Copy code
    ts
    export const storage = createCookieSessionStorage({
      cookie: {
        name: "session",
        secure: import.meta.env.PROD,
        secrets: [import.meta.env.SECRET], // I do not need nor want to know this
        sameSite: "lax",
        path: "/",
        maxAge: 60 * 60 * 24 * 30, // 30 days
        httpOnly: true
      }
    });
  • h

    HardAtWork

    02/21/2023, 2:21 PM
    Try this(replace
    pnpm
    with
    npm run
    , or your package manager of choice:
    Copy code
    sh
    head -c128 /dev/random | base64 | pnpm wrangler secret put SECRET
  • p

    Ping for toast

    02/21/2023, 2:22 PM
    oooh smart
  • d

    dave

    02/21/2023, 6:52 PM
    I'm hoping the CryptoKey bindings will allow us to generate a private key server side eventually. https://kian.org.uk/cryptokey-bindings-in-cloudflare-workers-importkey-at-publish-time/
  • d

    dave

    02/21/2023, 6:54 PM
    It's very limited in terms of situations where you can use mTLS, but if you can, this is the best IMO. https://developers.cloudflare.com/workers/runtime-apis/mtls/
  • k

    kian

    02/21/2023, 6:56 PM
    I expect it’ll be the same as mTLS where you can upload it with Wrangler - eventually
  • d

    dave

    02/21/2023, 6:57 PM
    question, how can I ensure that my Worker is being accessed with a valid mTLS cert? (i.e. the reverse of the link I just posted.)
  • k

    kian

    02/21/2023, 6:57 PM
    it’ll be in req.cf
  • k

    kian

    02/21/2023, 6:58 PM
    https://github.com/cloudflare/workerd/blob/main/types/defines/cf.d.ts#L552
  • s

    Skye

    02/21/2023, 7:13 PM
    you could also do it on the firewall side with an mTLS rule
  • d

    dave

    02/21/2023, 7:16 PM
    ah,
    request.cf?.tlsClientAuth
    ?
  • k

    kian

    02/21/2023, 7:17 PM
    Something like that - I’d just do
    return Response.json(req.cf)
    whilst testing and see what it returns
  • k

    kian

    02/21/2023, 7:18 PM
    Id recommend doing what Skye said too
  • k

    kian

    02/21/2023, 7:18 PM
    Stopping a bad request at the WAF won’t bill you for a Worker request
  • d

    dave

    02/21/2023, 8:31 PM
    Copy code
    Total Upload: 6054.66 KiB / gzip: 531.34 KiB
    How bad is this for perf? 😛
  • k

    kian

    02/21/2023, 8:32 PM
    should be fine
  • k

    kian

    02/21/2023, 8:32 PM
    add
    minify = true
    in wrangler.toml if you aren't already minifying yourself for extra space savings
  • d

    dave

    02/21/2023, 8:33 PM
    huh nice
    Copy code
    Total Upload: 2639.50 KiB / gzip: 374.98 KiB
  • d

    dave

    02/21/2023, 8:34 PM
    any downside with using
    node_compat = true
    ?
  • k

    kian

    02/21/2023, 8:35 PM
    adds lots of large polyfills you probably don't want/need
  • d

    dave

    02/21/2023, 9:25 PM
    shouldn't impact stability though right?
  • t

    Tom Sherman

    02/21/2023, 9:58 PM
    Is JS parsing included in CPU time measurements for billing and limits?
1...229522962297...2509Latest