OpenSSL - Subject does not start with '/' in OS X application
Asked Answered
A

1

0

I'm currently working on an application that collects information from text fields in an OS X application, then access the openssl binary to generate a CSR and a Private Key based on those text fields. Here is the current code

let keySizeValue = keySizes[keySizeChoice.indexOfSelectedItem]

mainTask.launchPath = "/usr/bin/openssl"
mainTask.arguments = ["req", "-new", "-newkey", "\(keySizeValue)", "-passout", "pass:\(privateKeyPassword.stringValue)","-keyout", "/Users/\(userName)/Desktop/Certs/\(privateKeyText.stringValue).key", "-subj" ,"\"/C=US/ST=\(stateText.stringValue)/L=\(cityText.stringValue)/O=\(organizationText.stringValue)/OU=\(departmentText.stringValue)/CN=\(commonNameText.stringValue)\"", "-out", "/Users/\(userName)/Desktop/Certs/MyNew.csr"]

let pipe = NSPipe()
mainTask.standardInput = pipe
mainTask.launch()
mainTask.waitUntilExit()
mainTask.terminate()

However i'm getting an error that states that Subject does not start with '/'. Was hoping someone could hit me up with some sort of idea as to why it is stating that my subject is not starting with that /, even though it clearly is.

Thanks all

Abbacy answered 23/12, 2015 at 17:1 Comment(0)
A
6

I found my answer. By pulling out the starting double quote before the subject call, and removing the ending double quote it actually imported the CSR subject correctly.

Abbacy answered 23/12, 2015 at 22:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.