macOS

package standard library
go1.22.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

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

Index

Constants

View Source
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
)

Variables

View Source
var ErrNoTrustSettings = errors.New("no trust settings found")
View Source
var SecPolicyAppleSSL = StringToCFString("1.2.840.113635.100.1.3") // defined by POLICYMACRO
View Source
var SecPolicyOid = StringToCFString("SecPolicyOid")
View Source
var SecTrustSettingsPolicy = StringToCFString("kSecTrustSettingsPolicy")
View Source
var SecTrustSettingsPolicyString = StringToCFString("kSecTrustSettingsPolicyString")
View Source
var SecTrustSettingsResultKey = StringToCFString("kSecTrustSettingsResult")

Functions

func CFArrayAppendValue added in go1.18

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 added in go1.18.10

func CFErrorGetCode(errRef CFRef) int

func CFNumberGetValue

func CFNumberGetValue(num CFRef) (int32, error)

func CFRelease

func CFRelease(ref CFRef)

func CFStringToString added in go1.18

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 added in go1.18

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 added in go1.18

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

func SecTrustEvaluateWithError added in go1.18

func SecTrustEvaluateWithError(trustObj CFRef) (int, error)

func SecTrustGetCertificateCount added in go1.18

func SecTrustGetCertificateCount(trustObj CFRef) int

func SecTrustGetResult added in go1.18

func SecTrustGetResult(trustObj CFRef, result CFRef) (CFRef, CFRef, error)

func SecTrustSetVerifyDate added in go1.18

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 added in go1.18

func BytesToCFData(b []byte) CFRef

func CFArrayCreateMutable added in go1.18

func CFArrayCreateMutable() CFRef

func CFArrayGetValueAtIndex

func CFArrayGetValueAtIndex(array CFRef, index int) CFRef

func CFDateCreate added in go1.18

func CFDateCreate(seconds float64) CFRef

func CFDictionaryGetValueIfPresent

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

func CFErrorCopyDescription added in go1.18

func CFErrorCopyDescription(errRef CFRef) CFRef

func CFStringCreateExternalRepresentation added in go1.18

func CFStringCreateExternalRepresentation(strRef CFRef) (CFRef, error)

func SecCertificateCreateWithData added in go1.18

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

func SecPolicyCreateSSL added in go1.18

func SecPolicyCreateSSL(name string) (CFRef, error)

func SecTrustCreateWithCertificates added in go1.18

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

func SecTrustEvaluate added in go1.18

func SecTrustEvaluate(trustObj CFRef) (CFRef, error)

func SecTrustGetCertificateAtIndex added in go1.18

func SecTrustGetCertificateAtIndex(trustObj CFRef, i int) (CFRef, error)

func SecTrustSettingsCopyCertificates

func SecTrustSettingsCopyCertificates(domain SecTrustSettingsDomain) (certArray CFRef, err error)

func SecTrustSettingsCopyTrustSettings

func SecTrustSettingsCopyTrustSettings(cert CFRef, domain SecTrustSettingsDomain) (trustSettings CFRef, err error)

func TimeToCFDateRef added in go1.18

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

type SecTrustResultType added in go1.18

type SecTrustResultType int32
const (
	SecTrustResultInvalid SecTrustResultType = iota
	SecTrustResultProceed
	SecTrustResultConfirm // deprecated
	SecTrustResultDeny
	SecTrustResultUnspecified
	SecTrustResultRecoverableTrustFailure
	SecTrustResultFatalTrustFailure
	SecTrustResultOtherError
)

type SecTrustSettingsDomain

type SecTrustSettingsDomain int32
const (
	SecTrustSettingsDomainUser SecTrustSettingsDomain = iota
	SecTrustSettingsDomainAdmin
	SecTrustSettingsDomainSystem
)

type SecTrustSettingsResult

type SecTrustSettingsResult int32
const (
	SecTrustSettingsResultInvalid SecTrustSettingsResult = iota
	SecTrustSettingsResultTrustRoot
	SecTrustSettingsResultTrustAsRoot
	SecTrustSettingsResultDeny
	SecTrustSettingsResultUnspecified
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL