-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Credentials::ConvertX509CertToChipCert
to Obj-C.
#22113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
#import "MTRCertificates.h" | ||
#import "MTRError_Internal.h" | ||
#import "MTRLogging.h" | ||
#import "MTRMemory.h" | ||
#import "MTROperationalCredentialsDelegate.h" | ||
#import "MTRP256KeypairBridge.h" | ||
|
@@ -196,4 +197,21 @@ + (nullable NSData *)generateCertificateSigningRequest:(id<MTRKeypair>)keypair | |
return nil; | ||
} | ||
|
||
+ (nullable NSData *)convertToCHIPCertFromX509Cert:(NSData *)x509Certificate | ||
{ | ||
|
||
chip::ByteSpan x509CertBytes = chip::ByteSpan((uint8_t *) x509Certificate.bytes, x509Certificate.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use AsByteSpan(). |
||
|
||
NSMutableData * chipCertBuffer = [[NSMutableData alloc] initWithLength:chip::Credentials::kMaxCHIPCertLength]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use a stack buffer. |
||
chip::MutableByteSpan chipCertBytes((uint8_t *) chipCertBuffer.mutableBytes, chip::Credentials::kMaxCHIPCertLength); | ||
|
||
CHIP_ERROR errorCode = chip::Credentials::ConvertX509CertToChipCert(x509CertBytes, chipCertBytes); | ||
MTR_LOG_ERROR("ConvertX509CertToChipCert: %{public}s", chip::ErrorStr(errorCode)); | ||
|
||
if (errorCode != CHIP_NO_ERROR) | ||
return nil; | ||
|
||
return [NSData dataWithBytes:chipCertBytes.data() length:chipCertBytes.size()]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to document when null is returned.