Handle CN greater than 64 character length

Summary:
This diff handles the case when the CN(subject Common) is greater than 64. CN in our case is an appId, which can be greater than 64 length. Have a look at this [issue](https://fb.workplace.com/groups/flippersupport/permalink/1142641402883183/). In this issue the appID was  `com.facebook.internal.focusrepresentativeapp.development.localDevelopment`

See this [discussion on stack](https://unix.stackexchange.com/questions/234324/openssl-self-signed-certificate-with-a-common-name-longer-than-64-bytes) overflow to understand about the limit of 64.

This diff checks the length first and then defaults the CN to be "com.flipper".

Reviewed By: jknoxville

Differential Revision: D28807389

fbshipit-source-id: ca01ccd5d31a51826df49f943414c42bf902be89
This commit is contained in:
Pritesh Nandgaonkar
2021-06-02 03:51:00 -07:00
committed by Facebook GitHub Bot
parent 85157fb948
commit b0b49e1098

View File

@@ -43,7 +43,7 @@ bool generateCertSigningRequest(
const char* subjectProvince = "CA"; const char* subjectProvince = "CA";
const char* subjectCity = "Menlo Park"; const char* subjectCity = "Menlo Park";
const char* subjectOrganization = "Flipper"; const char* subjectOrganization = "Flipper";
const char* subjectCommon = appId; const char* subjectCommon = strlen(appId) >= 64 ? "com.flipper" : appId;
X509_REQ* x509_req = X509_REQ_new(); X509_REQ* x509_req = X509_REQ_new();
EVP_PKEY* pKey = EVP_PKEY_new(); EVP_PKEY* pKey = EVP_PKEY_new();