package macOS

import "crypto/x509/internal/macos"

Package macOS provides cgo-less wrappers for Core Foundation and Security.framework, similarly to how package syscall provides access to libSystem.dylib.

Index

Constants

const (
	// various macOS error codes that can be returned from
	// SecTrustEvaluateWithError that we can map to Go cert
	// verification error types.
	ErrSecCertificateExpired = -67818
	ErrSecHostNameMismatch   = -67602
	ErrSecNotTrusted         = -67843
)

Functions

func CFArrayAppendValue

func CFArrayAppendValue(array CFRef, val CFRef)

func CFArrayGetCount

func CFArrayGetCount(array CFRef) int

func CFDataGetBytePtr

func CFDataGetBytePtr(data CFRef) uintptr

func CFDataGetLength

func CFDataGetLength(data CFRef) int

func CFDataToSlice

func CFDataToSlice(data CFRef) []byte

CFDataToSlice returns a copy of the contents of data as a bytes slice.

func CFEqual

func CFEqual(a, b CFRef) bool

func CFErrorGetCode

func CFErrorGetCode(errRef CFRef) int

func CFNumberGetValue

func CFNumberGetValue(num CFRef) (int32, error)

func CFRelease

func CFRelease(ref CFRef)

func CFStringToString

func CFStringToString(ref CFRef) string

CFStringToString returns a Go string representation of the passed in CFString, or an empty string if it's invalid.

func ReleaseCFArray

func ReleaseCFArray(array CFRef)

ReleaseCFArray iterates through an array, releasing its contents, and then releases the array itself. This is necessary because we cannot, easily, set the CFArrayCallBacks argument when creating CFArrays.

func SecCertificateCopyData

func SecCertificateCopyData(cert CFRef) ([]byte, error)

func SecTrustEvaluateWithError

func SecTrustEvaluateWithError(trustObj CFRef) (int, error)

func SecTrustSetVerifyDate

func SecTrustSetVerifyDate(trustObj CFRef, dateRef CFRef) error

Types

type CFRef

type CFRef uintptr

CFRef is an opaque reference to a Core Foundation object. It is a pointer, but to memory not owned by Go, so not an unsafe.Pointer.

func BytesToCFData

func BytesToCFData(b []byte) CFRef

func CFArrayCreateMutable

func CFArrayCreateMutable() CFRef

func CFArrayGetValueAtIndex

func CFArrayGetValueAtIndex(array CFRef, index int) CFRef

func CFDateCreate

func CFDateCreate(seconds float64) CFRef

func CFDictionaryGetValueIfPresent

func CFDictionaryGetValueIfPresent(dict CFRef, key CFString) (value CFRef, ok bool)

func CFErrorCopyDescription

func CFErrorCopyDescription(errRef CFRef) CFRef

func CFStringCreateExternalRepresentation

func CFStringCreateExternalRepresentation(strRef CFRef) (CFRef, error)

func SecCertificateCreateWithData

func SecCertificateCreateWithData(b []byte) (CFRef, error)

func SecPolicyCreateSSL

func SecPolicyCreateSSL(name string) (CFRef, error)

func SecTrustCopyCertificateChain

func SecTrustCopyCertificateChain(trustObj CFRef) (CFRef, error)

func SecTrustCreateWithCertificates

func SecTrustCreateWithCertificates(certs CFRef, policies CFRef) (CFRef, error)

func SecTrustEvaluate

func SecTrustEvaluate(trustObj CFRef) (CFRef, error)

func TimeToCFDateRef

func TimeToCFDateRef(t time.Time) CFRef

TimeToCFDateRef converts a time.Time into an apple CFDateRef.

type CFString

type CFString CFRef

func StringToCFString

func StringToCFString(s string) CFString

StringToCFString returns a copy of the UTF-8 contents of s as a new CFString.

type OSStatus

type OSStatus struct {
	// contains filtered or unexported fields
}

func (OSStatus) Error

func (s OSStatus) Error() string

Source Files

corefoundation.go security.go

Version
v1.25.0-rc.1
Published
Jun 11, 2025
Platform
darwin/amd64
Imports
7 packages
Last checked
56 seconds ago

Tools for package owners.