Giter VIP home page Giter VIP logo

Comments (4)

cbaker6 avatar cbaker6 commented on May 26, 2024

Hi @iosdevninja,

I checked one of my generated certificates and I don't run into this issue. I have attached a screenshot for reference.

My thinking is this is not an issue with this framework but an issue with your code. My reasoning for this is I quickly looked through your code (I don't have much time this week) and see a problem which could be causing your issue. Line 101 of your code you have:

let csrString = csrBuild.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0))

This will not work. In iOSCSRSwiftTests.swift, I state this should be:

let csrString = csrBuild.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)).addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)

The line below should work as well (depending on your swift version):

let csrString = csrBuild.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)).stringByAddingPercentEncodingForFormUrlencoded()!

Encoding incorrectly will definitely cause your CSR to fail.

CSR Decoder and Certificate Decoder.pdf

If there is still an issue, I won't be able to look at it until next week.

Let me know if this solves your problem.

from certificatesigningrequest.

iosdevninja avatar iosdevninja commented on May 26, 2024

Hello Corey,

Thank you very much for your prompt reply.

I did the code change as you suggested (Swift 3 one)

let csrString = csrBuild.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)).addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)

and then print out the new generated CSR string.

I am enclosing it as an attachment on this thread.

The problem is it is still NOT working when tested in https://redkestrel.co.uk/products/decoder/

If you check on the new generated CSR now it comes with % values all across the text.

Please provide advice when you have a free moment.

Kind regards

CSR_After_Code_Change.zip

from certificatesigningrequest.

cbaker6 avatar cbaker6 commented on May 26, 2024

@iosdevninja it appears the encoding line I gave you earlier was still correct. Correcting two lines of your code will fix your problem:

let csrString = csrBuild.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)

let formattedCSRString = String(format:"%@%@%@","-----BEGIN CERTIFICATE REQUEST-----\n", csrString!, "\n-----END CERTIFICATE REQUEST-----\n")

I have attached the CSR created using your code. My apologies for the late reply.

If there is still an issue, this string extension seems to encode perfectly:

CSR Decoder and Certificate Decoder.pdf

from certificatesigningrequest.

cbaker6 avatar cbaker6 commented on May 26, 2024

@iosdevninja I added two methods which encodes the CSR for you:

Full CSR string:
let builtCSR = csr.buildCSRAndReturnString(publicKeyBits, privateKey: privateKey)

CSR without header and footer:
let builtCSR = csr.buildAndEncodeDataAsString(publicKeyBits, privateKey: privateKey)

from certificatesigningrequest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.