Skip to content

example of adding othername SAN to a CSR? #16

Description

@learningSwif

Hi,
In my csr, i'd like to be able to include a UPN value for the SAN. In openssl's configuration, this would appear in the following form: subjectAltName = otherName:1.3.18.0.2.4.318;UTF8:test@example.com
I see CertificateRequestBuilder() accepts 'otherName' as a parameter, but since i'm new to swift, I'm not sure how to create the proper data for that parameter. Can anyone provide an example that shows how to accomplish this?
Just for reference, this is an example that i'm starting from

let csr =
try CertificationRequest.Builder()
.subject(name: NameBuilder().add("Outfox Signing", forTypeName: "CN").name)
.alternativeNames(names: .otherName(???HOW TO POPULATE THIS???))
.publicKey(keyPair: Self.keyPair, usage: [.keyEncipherment])
.extendedKeyUsage(keyPurposes: [kp.clientAuth.oid, kp.serverAuth.oid], isCritical: true)
.build(signingKey: Self.keyPair.privateKey, digestAlgorithm: .sha256)

output(csr)

Thanks!

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