public static SafeSecCertificateHandle GetCertificate(SafeSecIdentityHandle identity) { if (identity == null || identity.IsInvalid) { throw new ArgumentNullException(nameof(identity)); } var result = SecIdentityCopyCertificate(identity.DangerousGetHandle(), out var cert); if (result != SecStatusCode.Success) { throw new InvalidOperationException(result.ToString()); } return(new SafeSecCertificateHandle(cert, true)); }
CFArray Bundle(SafeSecIdentityHandle identity, IList <SafeSecCertificateHandle> certificates) { if (identity == null || identity.IsInvalid) { throw new ArgumentNullException(nameof(identity)); } if (certificates == null) { throw new ArgumentNullException(nameof(certificates)); } var ptrs = new IntPtr [certificates.Count + 1]; ptrs [0] = identity.DangerousGetHandle(); for (int i = 0; i < certificates.Count; i++) { ptrs [i + 1] = certificates [i].DangerousGetHandle(); } return(CFArray.CreateArray(ptrs)); }