v0.2.2 9100209

gtlscertificate.go RawHistoryFolder

1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type TlsCertificateClass struct {
17	_ structs.HostLayout
18
19	ParentClass gobject.ObjectClass
20
21	xVerify uintptr
22
23	Padding [8]uintptr
24}
25
26func (x *TlsCertificateClass) GoPointer() uintptr {
27	return uintptr(unsafe.Pointer(x))
28}
29
30// OverrideVerify sets the "verify" callback function.
31func (x *TlsCertificateClass) OverrideVerify(cb func(*TlsCertificate, SocketConnectable, *TlsCertificate) TlsCertificateFlags) {
32	if cb == nil {
33		x.xVerify = 0
34	} else {
35		x.xVerify = purego.NewCallback(func(CertVarp uintptr, IdentityVarp uintptr, TrustedCaVarp uintptr) TlsCertificateFlags {
36			return cb(TlsCertificateNewFromInternalPtr(CertVarp), &SocketConnectableBase{Ptr: IdentityVarp}, TlsCertificateNewFromInternalPtr(TrustedCaVarp))
37		})
38	}
39}
40
41// GetVerify gets the "verify" callback function.
42func (x *TlsCertificateClass) GetVerify() func(*TlsCertificate, SocketConnectable, *TlsCertificate) TlsCertificateFlags {
43	if x.xVerify == 0 {
44		return nil
45	}
46	var rawCallback func(CertVarp uintptr, IdentityVarp uintptr, TrustedCaVarp uintptr) TlsCertificateFlags
47	purego.RegisterFunc(&rawCallback, x.xVerify)
48	return func(CertVar *TlsCertificate, IdentityVar SocketConnectable, TrustedCaVar *TlsCertificate) TlsCertificateFlags {
49		return rawCallback(CertVar.GoPointer(), IdentityVar.GoPointer(), TrustedCaVar.GoPointer())
50	}
51}
52
53type TlsCertificatePrivate struct {
54	_ structs.HostLayout
55}
56
57func (x *TlsCertificatePrivate) GoPointer() uintptr {
58	return uintptr(unsafe.Pointer(x))
59}
60
61// A certificate used for TLS authentication and encryption.
62// This can represent either a certificate only (eg, the certificate
63// received by a client from a server), or the combination of
64// a certificate and a private key (which is needed when acting as a
65// [iface@Gio.TlsServerConnection]).
66type TlsCertificate struct {
67	gobject.Object
68}
69
70var xTlsCertificateGLibType func() types.GType
71
72func TlsCertificateGLibType() types.GType {
73	return xTlsCertificateGLibType()
74}
75
76func TlsCertificateNewFromInternalPtr(ptr uintptr) *TlsCertificate {
77	cls := &TlsCertificate{}
78	cls.Ptr = ptr
79	return cls
80}
81
82var xNewTlsCertificateFromFile func(string, **glib.Error) uintptr
83
84// Creates a #GTlsCertificate from the data in @file.
85//
86// As of 2.72, if the filename ends in `.p12` or `.pfx` the data is loaded by
87// g_tls_certificate_new_from_pkcs12() otherwise it is loaded by
88// g_tls_certificate_new_from_pem(). See those functions for
89// exact details.
90//
91// If @file cannot be read or parsed, the function will return %NULL and
92// set @error.
93func NewTlsCertificateFromFile(FileVar string) (*TlsCertificate, error) {
94	var cls *TlsCertificate
95	var cerr *glib.Error
96
97	cret := xNewTlsCertificateFromFile(FileVar, &cerr)
98
99	if cret == 0 {
100		return nil, cerr
101	}
102	cls = &TlsCertificate{}
103	cls.Ptr = cret
104	if cerr == nil {
105		return cls, nil
106	}
107	return cls, cerr
108
109}
110
111var xNewTlsCertificateFromFileWithPassword func(string, string, **glib.Error) uintptr
112
113// Creates a #GTlsCertificate from the data in @file.
114//
115// If @file cannot be read or parsed, the function will return %NULL and
116// set @error.
117//
118// Any unknown file types will error with %G_IO_ERROR_NOT_SUPPORTED.
119// Currently only `.p12` and `.pfx` files are supported.
120// See g_tls_certificate_new_from_pkcs12() for more details.
121func NewTlsCertificateFromFileWithPassword(FileVar string, PasswordVar string) (*TlsCertificate, error) {
122	var cls *TlsCertificate
123	var cerr *glib.Error
124
125	cret := xNewTlsCertificateFromFileWithPassword(FileVar, PasswordVar, &cerr)
126
127	if cret == 0 {
128		return nil, cerr
129	}
130	cls = &TlsCertificate{}
131	cls.Ptr = cret
132	if cerr == nil {
133		return cls, nil
134	}
135	return cls, cerr
136
137}
138
139var xNewTlsCertificateFromFiles func(string, string, **glib.Error) uintptr
140
141// Creates a #GTlsCertificate from the PEM-encoded data in @cert_file
142// and @key_file. The returned certificate will be the first certificate
143// found in @cert_file. As of GLib 2.44, if @cert_file contains more
144// certificates it will try to load a certificate chain. All
145// certificates will be verified in the order found (top-level
146// certificate should be the last one in the file) and the
147// #GTlsCertificate:issuer property of each certificate will be set
148// accordingly if the verification succeeds. If any certificate in the
149// chain cannot be verified, the first certificate in the file will
150// still be returned.
151//
152// If either file cannot be read or parsed, the function will return
153// %NULL and set @error. Otherwise, this behaves like
154// g_tls_certificate_new_from_pem().
155func NewTlsCertificateFromFiles(CertFileVar string, KeyFileVar string) (*TlsCertificate, error) {
156	var cls *TlsCertificate
157	var cerr *glib.Error
158
159	cret := xNewTlsCertificateFromFiles(CertFileVar, KeyFileVar, &cerr)
160
161	if cret == 0 {
162		return nil, cerr
163	}
164	cls = &TlsCertificate{}
165	cls.Ptr = cret
166	if cerr == nil {
167		return cls, nil
168	}
169	return cls, cerr
170
171}
172
173var xNewTlsCertificateFromPem func(string, int, **glib.Error) uintptr
174
175// Creates a #GTlsCertificate from the PEM-encoded data in @data. If
176// @data includes both a certificate and a private key, then the
177// returned certificate will include the private key data as well. (See
178// the #GTlsCertificate:private-key-pem property for information about
179// supported formats.)
180//
181// The returned certificate will be the first certificate found in
182// @data. As of GLib 2.44, if @data contains more certificates it will
183// try to load a certificate chain. All certificates will be verified in
184// the order found (top-level certificate should be the last one in the
185// file) and the #GTlsCertificate:issuer property of each certificate
186// will be set accordingly if the verification succeeds. If any
187// certificate in the chain cannot be verified, the first certificate in
188// the file will still be returned.
189func NewTlsCertificateFromPem(DataVar string, LengthVar int) (*TlsCertificate, error) {
190	var cls *TlsCertificate
191	var cerr *glib.Error
192
193	cret := xNewTlsCertificateFromPem(DataVar, LengthVar, &cerr)
194
195	if cret == 0 {
196		return nil, cerr
197	}
198	cls = &TlsCertificate{}
199	cls.Ptr = cret
200	if cerr == nil {
201		return cls, nil
202	}
203	return cls, cerr
204
205}
206
207var xNewTlsCertificateFromPkcs11Uris func(string, uintptr, **glib.Error) uintptr
208
209// Creates a #GTlsCertificate from a
210// [PKCS \#11](https://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html) URI.
211//
212// An example @pkcs11_uri would be `pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01`
213//
214// Where the token’s layout is:
215//
216// |[
217// Object 0:
218//
219//	URL: pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01;object=private%20key;type=private
220//	Type: Private key (RSA-2048)
221//	ID: 01
222//
223// Object 1:
224//
225//	URL: pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01;object=Certificate%20for%20Authentication;type=cert
226//	Type: X.509 Certificate (RSA-2048)
227//	ID: 01
228//
229// ]|
230//
231// In this case the certificate and private key would both be detected and used as expected.
232// @pkcs_uri may also just reference an X.509 certificate object and then optionally
233// @private_key_pkcs11_uri allows using a private key exposed under a different URI.
234//
235// Note that the private key is not accessed until usage and may fail or require a PIN later.
236func NewTlsCertificateFromPkcs11Uris(Pkcs11UriVar string, PrivateKeyPkcs11UriVar *string) (*TlsCertificate, error) {
237	var cls *TlsCertificate
238	var cerr *glib.Error
239
240	PrivateKeyPkcs11UriVarPtr := core.GStrdupNullable(PrivateKeyPkcs11UriVar)
241	defer core.GFreeNullable(PrivateKeyPkcs11UriVarPtr)
242
243	cret := xNewTlsCertificateFromPkcs11Uris(Pkcs11UriVar, PrivateKeyPkcs11UriVarPtr, &cerr)
244
245	if cret == 0 {
246		return nil, cerr
247	}
248	cls = &TlsCertificate{}
249	cls.Ptr = cret
250	if cerr == nil {
251		return cls, nil
252	}
253	return cls, cerr
254
255}
256
257var xNewTlsCertificateFromPkcs12 func([]byte, uint, uintptr, **glib.Error) uintptr
258
259// Creates a #GTlsCertificate from the data in @data. It must contain
260// a certificate and matching private key.
261//
262// If extra certificates are included they will be verified as a chain
263// and the #GTlsCertificate:issuer property will be set.
264// All other data will be ignored.
265//
266// You can pass as single password for all of the data which will be
267// used both for the PKCS #12 container as well as encrypted
268// private keys. If decryption fails it will error with
269// %G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD.
270//
271// This constructor requires support in the current #GTlsBackend.
272// If support is missing it will error with
273// %G_IO_ERROR_NOT_SUPPORTED.
274//
275// Other parsing failures will error with %G_TLS_ERROR_BAD_CERTIFICATE.
276func NewTlsCertificateFromPkcs12(DataVar []byte, LengthVar uint, PasswordVar *string) (*TlsCertificate, error) {
277	var cls *TlsCertificate
278	var cerr *glib.Error
279
280	PasswordVarPtr := core.GStrdupNullable(PasswordVar)
281	defer core.GFreeNullable(PasswordVarPtr)
282
283	cret := xNewTlsCertificateFromPkcs12(DataVar, LengthVar, PasswordVarPtr, &cerr)
284
285	if cret == 0 {
286		return nil, cerr
287	}
288	cls = &TlsCertificate{}
289	cls.Ptr = cret
290	if cerr == nil {
291		return cls, nil
292	}
293	return cls, cerr
294
295}
296
297var xTlsCertificateGetDnsNames func(uintptr) uintptr
298
299// Gets the value of #GTlsCertificate:dns-names.
300func (x *TlsCertificate) GetDnsNames() uintptr {
301
302	cret := xTlsCertificateGetDnsNames(x.GoPointer())
303	return cret
304}
305
306var xTlsCertificateGetIpAddresses func(uintptr) uintptr
307
308// Gets the value of #GTlsCertificate:ip-addresses.
309func (x *TlsCertificate) GetIpAddresses() uintptr {
310
311	cret := xTlsCertificateGetIpAddresses(x.GoPointer())
312	return cret
313}
314
315var xTlsCertificateGetIssuer func(uintptr) uintptr
316
317// Gets the #GTlsCertificate representing @cert's issuer, if known
318func (x *TlsCertificate) GetIssuer() *TlsCertificate {
319	var cls *TlsCertificate
320
321	cret := xTlsCertificateGetIssuer(x.GoPointer())
322
323	if cret == 0 {
324		return nil
325	}
326	gobject.IncreaseRef(cret)
327	cls = &TlsCertificate{}
328	cls.Ptr = cret
329	return cls
330}
331
332var xTlsCertificateGetIssuerName func(uintptr) string
333
334// Returns the issuer name from the certificate.
335func (x *TlsCertificate) GetIssuerName() string {
336
337	cret := xTlsCertificateGetIssuerName(x.GoPointer())
338	return cret
339}
340
341var xTlsCertificateGetNotValidAfter func(uintptr) *glib.DateTime
342
343// Returns the time at which the certificate became or will become invalid.
344func (x *TlsCertificate) GetNotValidAfter() *glib.DateTime {
345
346	cret := xTlsCertificateGetNotValidAfter(x.GoPointer())
347	return cret
348}
349
350var xTlsCertificateGetNotValidBefore func(uintptr) *glib.DateTime
351
352// Returns the time at which the certificate became or will become valid.
353func (x *TlsCertificate) GetNotValidBefore() *glib.DateTime {
354
355	cret := xTlsCertificateGetNotValidBefore(x.GoPointer())
356	return cret
357}
358
359var xTlsCertificateGetSubjectName func(uintptr) string
360
361// Returns the subject name from the certificate.
362func (x *TlsCertificate) GetSubjectName() string {
363
364	cret := xTlsCertificateGetSubjectName(x.GoPointer())
365	return cret
366}
367
368var xTlsCertificateIsSame func(uintptr, uintptr) bool
369
370// Check if two #GTlsCertificate objects represent the same certificate.
371// The raw DER byte data of the two certificates are checked for equality.
372// This has the effect that two certificates may compare equal even if
373// their #GTlsCertificate:issuer, #GTlsCertificate:private-key, or
374// #GTlsCertificate:private-key-pem properties differ.
375func (x *TlsCertificate) IsSame(CertTwoVar *TlsCertificate) bool {
376
377	cret := xTlsCertificateIsSame(x.GoPointer(), CertTwoVar.GoPointer())
378	return cret
379}
380
381var xTlsCertificateVerify func(uintptr, uintptr, uintptr) TlsCertificateFlags
382
383// This verifies @cert and returns a set of #GTlsCertificateFlags
384// indicating any problems found with it. This can be used to verify a
385// certificate outside the context of making a connection, or to
386// check a certificate against a CA that is not part of the system
387// CA database.
388//
389// If @cert is valid, %G_TLS_CERTIFICATE_NO_FLAGS is returned.
390//
391// If @identity is not %NULL, @cert's name(s) will be compared against
392// it, and %G_TLS_CERTIFICATE_BAD_IDENTITY will be set in the return
393// value if it does not match. If @identity is %NULL, that bit will
394// never be set in the return value.
395//
396// If @trusted_ca is not %NULL, then @cert (or one of the certificates
397// in its chain) must be signed by it, or else
398// %G_TLS_CERTIFICATE_UNKNOWN_CA will be set in the return value. If
399// @trusted_ca is %NULL, that bit will never be set in the return
400// value.
401//
402// GLib guarantees that if certificate verification fails, at least one
403// error will be set in the return value, but it does not guarantee
404// that all possible errors will be set. Accordingly, you may not safely
405// decide to ignore any particular type of error. For example, it would
406// be incorrect to mask %G_TLS_CERTIFICATE_EXPIRED if you want to allow
407// expired certificates, because this could potentially be the only
408// error flag set even if other problems exist with the certificate.
409//
410// Because TLS session context is not used, #GTlsCertificate may not
411// perform as many checks on the certificates as #GTlsConnection would.
412// For example, certificate constraints may not be honored, and
413// revocation checks may not be performed. The best way to verify TLS
414// certificates used by a TLS connection is to let #GTlsConnection
415// handle the verification.
416func (x *TlsCertificate) Verify(IdentityVar SocketConnectable, TrustedCaVar *TlsCertificate) TlsCertificateFlags {
417
418	cret := xTlsCertificateVerify(x.GoPointer(), IdentityVar.GoPointer(), TrustedCaVar.GoPointer())
419	return cret
420}
421
422func (c *TlsCertificate) GoPointer() uintptr {
423	if c == nil {
424		return 0
425	}
426	return c.Ptr
427}
428
429func (c *TlsCertificate) SetGoPointer(ptr uintptr) {
430	c.Ptr = ptr
431}
432
433// SetPropertyCertificate sets the "certificate" property.
434// The DER (binary) encoded representation of the certificate.
435// This property and the #GTlsCertificate:certificate-pem property
436// represent the same data, just in different forms.
437func (x *TlsCertificate) SetPropertyCertificate(value []byte) {
438	var v gobject.Value
439	v.Init(glib.ByteArrayGLibType())
440	v.SetBoxed(uintptr(unsafe.Pointer(&value[0])))
441	x.SetProperty("certificate", &v)
442}
443
444// GetPropertyCertificate gets the "certificate" property.
445// The DER (binary) encoded representation of the certificate.
446// This property and the #GTlsCertificate:certificate-pem property
447// represent the same data, just in different forms.
448func (x *TlsCertificate) GetPropertyCertificate() []byte {
449	var v gobject.Value
450	x.GetProperty("certificate", &v)
451	ptr := v.GetBoxed()
452	if ptr == 0 {
453		return nil
454	}
455	// GByteArray layout: { guint8 *data; guint len; }
456	dataPtr := *(*uintptr)(unsafe.Pointer(ptr))
457	length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0))))
458	if length == 0 || dataPtr == 0 {
459		return nil
460	}
461	return unsafe.Slice((*byte)(unsafe.Pointer(dataPtr)), length)
462}
463
464// SetPropertyCertificatePem sets the "certificate-pem" property.
465// The PEM (ASCII) encoded representation of the certificate.
466// This property and the #GTlsCertificate:certificate
467// property represent the same data, just in different forms.
468func (x *TlsCertificate) SetPropertyCertificatePem(value string) {
469	var v gobject.Value
470	v.Init(gobject.TypeStringVal)
471	v.SetString(&value)
472	x.SetProperty("certificate-pem", &v)
473}
474
475// GetPropertyCertificatePem gets the "certificate-pem" property.
476// The PEM (ASCII) encoded representation of the certificate.
477// This property and the #GTlsCertificate:certificate
478// property represent the same data, just in different forms.
479func (x *TlsCertificate) GetPropertyCertificatePem() string {
480	var v gobject.Value
481	x.GetProperty("certificate-pem", &v)
482	return v.GetString()
483}
484
485// GetPropertyDnsNames gets the "dns-names" property.
486// The DNS names from the certificate's Subject Alternative Names (SANs),
487// %NULL if unavailable.
488func (x *TlsCertificate) GetPropertyDnsNames() []uintptr {
489	var v gobject.Value
490	x.GetProperty("dns-names", &v)
491	ptr := v.GetBoxed()
492	if ptr == 0 {
493		return nil
494	}
495	// GPtrArray layout: { gpointer *pdata; guint len; }
496	dataPtr := *(*uintptr)(unsafe.Pointer(ptr))
497	length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0))))
498	if length == 0 || dataPtr == 0 {
499		return nil
500	}
501	return unsafe.Slice((*uintptr)(unsafe.Pointer(dataPtr)), length)
502}
503
504// GetPropertyIpAddresses gets the "ip-addresses" property.
505// The IP addresses from the certificate's Subject Alternative Names (SANs),
506// %NULL if unavailable.
507func (x *TlsCertificate) GetPropertyIpAddresses() []uintptr {
508	var v gobject.Value
509	x.GetProperty("ip-addresses", &v)
510	ptr := v.GetBoxed()
511	if ptr == 0 {
512		return nil
513	}
514	// GPtrArray layout: { gpointer *pdata; guint len; }
515	dataPtr := *(*uintptr)(unsafe.Pointer(ptr))
516	length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0))))
517	if length == 0 || dataPtr == 0 {
518		return nil
519	}
520	return unsafe.Slice((*uintptr)(unsafe.Pointer(dataPtr)), length)
521}
522
523// GetPropertyIssuerName gets the "issuer-name" property.
524// The issuer from the certificate,
525// %NULL if unavailable.
526func (x *TlsCertificate) GetPropertyIssuerName() string {
527	var v gobject.Value
528	x.GetProperty("issuer-name", &v)
529	return v.GetString()
530}
531
532// GetPropertyNotValidAfter gets the "not-valid-after" property.
533// The time at which this cert is no longer valid,
534// %NULL if unavailable.
535func (x *TlsCertificate) GetPropertyNotValidAfter() uintptr {
536	var v gobject.Value
537	x.GetProperty("not-valid-after", &v)
538	return v.GetPointer()
539}
540
541// GetPropertyNotValidBefore gets the "not-valid-before" property.
542// The time at which this cert is considered to be valid,
543// %NULL if unavailable.
544func (x *TlsCertificate) GetPropertyNotValidBefore() uintptr {
545	var v gobject.Value
546	x.GetProperty("not-valid-before", &v)
547	return v.GetPointer()
548}
549
550// SetPropertyPassword sets the "password" property.
551// An optional password used when constructed with GTlsCertificate:pkcs12-data.
552func (x *TlsCertificate) SetPropertyPassword(value string) {
553	var v gobject.Value
554	v.Init(gobject.TypeStringVal)
555	v.SetString(&value)
556	x.SetProperty("password", &v)
557}
558
559// SetPropertyPkcs11Uri sets the "pkcs11-uri" property.
560// A URI referencing the [PKCS \#11](https://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html)
561// objects containing an X.509 certificate and optionally a private key.
562//
563// If %NULL, the certificate is either not backed by PKCS \#11 or the
564// #GTlsBackend does not support PKCS \#11.
565func (x *TlsCertificate) SetPropertyPkcs11Uri(value string) {
566	var v gobject.Value
567	v.Init(gobject.TypeStringVal)
568	v.SetString(&value)
569	x.SetProperty("pkcs11-uri", &v)
570}
571
572// GetPropertyPkcs11Uri gets the "pkcs11-uri" property.
573// A URI referencing the [PKCS \#11](https://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html)
574// objects containing an X.509 certificate and optionally a private key.
575//
576// If %NULL, the certificate is either not backed by PKCS \#11 or the
577// #GTlsBackend does not support PKCS \#11.
578func (x *TlsCertificate) GetPropertyPkcs11Uri() string {
579	var v gobject.Value
580	x.GetProperty("pkcs11-uri", &v)
581	return v.GetString()
582}
583
584// SetPropertyPkcs12Data sets the "pkcs12-data" property.
585// The PKCS #12 formatted data used to construct the object.
586//
587// See also: g_tls_certificate_new_from_pkcs12()
588func (x *TlsCertificate) SetPropertyPkcs12Data(value []byte) {
589	var v gobject.Value
590	v.Init(glib.ByteArrayGLibType())
591	v.SetBoxed(uintptr(unsafe.Pointer(&value[0])))
592	x.SetProperty("pkcs12-data", &v)
593}
594
595// SetPropertyPrivateKey sets the "private-key" property.
596// The DER (binary) encoded representation of the certificate's
597// private key, in either [PKCS \#1 format](https://datatracker.ietf.org/doc/html/rfc8017)
598// or unencrypted [PKCS \#8 format.](https://datatracker.ietf.org/doc/html/rfc5208)
599// PKCS \#8 format is supported since 2.32; earlier releases only
600// support PKCS \#1. You can use the `openssl rsa` tool to convert
601// PKCS \#8 keys to PKCS \#1.
602//
603// This property (or the #GTlsCertificate:private-key-pem property)
604// can be set when constructing a key (for example, from a file).
605// Since GLib 2.70, it is now also readable; however, be aware that if
606// the private key is backed by a PKCS \#11 URI – for example, if it
607// is stored on a smartcard – then this property will be %NULL. If so,
608// the private key must be referenced via its PKCS \#11 URI,
609// #GTlsCertificate:private-key-pkcs11-uri. You must check both
610// properties to see if the certificate really has a private key.
611// When this property is read, the output format will be unencrypted
612// PKCS \#8.
613func (x *TlsCertificate) SetPropertyPrivateKey(value []byte) {
614	var v gobject.Value
615	v.Init(glib.ByteArrayGLibType())
616	v.SetBoxed(uintptr(unsafe.Pointer(&value[0])))
617	x.SetProperty("private-key", &v)
618}
619
620// GetPropertyPrivateKey gets the "private-key" property.
621// The DER (binary) encoded representation of the certificate's
622// private key, in either [PKCS \#1 format](https://datatracker.ietf.org/doc/html/rfc8017)
623// or unencrypted [PKCS \#8 format.](https://datatracker.ietf.org/doc/html/rfc5208)
624// PKCS \#8 format is supported since 2.32; earlier releases only
625// support PKCS \#1. You can use the `openssl rsa` tool to convert
626// PKCS \#8 keys to PKCS \#1.
627//
628// This property (or the #GTlsCertificate:private-key-pem property)
629// can be set when constructing a key (for example, from a file).
630// Since GLib 2.70, it is now also readable; however, be aware that if
631// the private key is backed by a PKCS \#11 URI – for example, if it
632// is stored on a smartcard – then this property will be %NULL. If so,
633// the private key must be referenced via its PKCS \#11 URI,
634// #GTlsCertificate:private-key-pkcs11-uri. You must check both
635// properties to see if the certificate really has a private key.
636// When this property is read, the output format will be unencrypted
637// PKCS \#8.
638func (x *TlsCertificate) GetPropertyPrivateKey() []byte {
639	var v gobject.Value
640	x.GetProperty("private-key", &v)
641	ptr := v.GetBoxed()
642	if ptr == 0 {
643		return nil
644	}
645	// GByteArray layout: { guint8 *data; guint len; }
646	dataPtr := *(*uintptr)(unsafe.Pointer(ptr))
647	length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0))))
648	if length == 0 || dataPtr == 0 {
649		return nil
650	}
651	return unsafe.Slice((*byte)(unsafe.Pointer(dataPtr)), length)
652}
653
654// SetPropertyPrivateKeyPem sets the "private-key-pem" property.
655// The PEM (ASCII) encoded representation of the certificate's
656// private key in either [PKCS \#1 format](https://datatracker.ietf.org/doc/html/rfc8017)
657// ("`BEGIN RSA PRIVATE KEY`") or unencrypted
658// [PKCS \#8 format](https://datatracker.ietf.org/doc/html/rfc5208)
659// ("`BEGIN PRIVATE KEY`"). PKCS \#8 format is supported since 2.32;
660// earlier releases only support PKCS \#1. You can use the `openssl rsa`
661// tool to convert PKCS \#8 keys to PKCS \#1.
662//
663// This property (or the #GTlsCertificate:private-key property)
664// can be set when constructing a key (for example, from a file).
665// Since GLib 2.70, it is now also readable; however, be aware that if
666// the private key is backed by a PKCS \#11 URI - for example, if it
667// is stored on a smartcard - then this property will be %NULL. If so,
668// the private key must be referenced via its PKCS \#11 URI,
669// #GTlsCertificate:private-key-pkcs11-uri. You must check both
670// properties to see if the certificate really has a private key.
671// When this property is read, the output format will be unencrypted
672// PKCS \#8.
673func (x *TlsCertificate) SetPropertyPrivateKeyPem(value string) {
674	var v gobject.Value
675	v.Init(gobject.TypeStringVal)
676	v.SetString(&value)
677	x.SetProperty("private-key-pem", &v)
678}
679
680// GetPropertyPrivateKeyPem gets the "private-key-pem" property.
681// The PEM (ASCII) encoded representation of the certificate's
682// private key in either [PKCS \#1 format](https://datatracker.ietf.org/doc/html/rfc8017)
683// ("`BEGIN RSA PRIVATE KEY`") or unencrypted
684// [PKCS \#8 format](https://datatracker.ietf.org/doc/html/rfc5208)
685// ("`BEGIN PRIVATE KEY`"). PKCS \#8 format is supported since 2.32;
686// earlier releases only support PKCS \#1. You can use the `openssl rsa`
687// tool to convert PKCS \#8 keys to PKCS \#1.
688//
689// This property (or the #GTlsCertificate:private-key property)
690// can be set when constructing a key (for example, from a file).
691// Since GLib 2.70, it is now also readable; however, be aware that if
692// the private key is backed by a PKCS \#11 URI - for example, if it
693// is stored on a smartcard - then this property will be %NULL. If so,
694// the private key must be referenced via its PKCS \#11 URI,
695// #GTlsCertificate:private-key-pkcs11-uri. You must check both
696// properties to see if the certificate really has a private key.
697// When this property is read, the output format will be unencrypted
698// PKCS \#8.
699func (x *TlsCertificate) GetPropertyPrivateKeyPem() string {
700	var v gobject.Value
701	x.GetProperty("private-key-pem", &v)
702	return v.GetString()
703}
704
705// SetPropertyPrivateKeyPkcs11Uri sets the "private-key-pkcs11-uri" property.
706// A URI referencing a [PKCS \#11](https://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html)
707// object containing a private key.
708func (x *TlsCertificate) SetPropertyPrivateKeyPkcs11Uri(value string) {
709	var v gobject.Value
710	v.Init(gobject.TypeStringVal)
711	v.SetString(&value)
712	x.SetProperty("private-key-pkcs11-uri", &v)
713}
714
715// GetPropertyPrivateKeyPkcs11Uri gets the "private-key-pkcs11-uri" property.
716// A URI referencing a [PKCS \#11](https://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html)
717// object containing a private key.
718func (x *TlsCertificate) GetPropertyPrivateKeyPkcs11Uri() string {
719	var v gobject.Value
720	x.GetProperty("private-key-pkcs11-uri", &v)
721	return v.GetString()
722}
723
724// GetPropertySubjectName gets the "subject-name" property.
725// The subject from the cert,
726// %NULL if unavailable.
727func (x *TlsCertificate) GetPropertySubjectName() string {
728	var v gobject.Value
729	x.GetProperty("subject-name", &v)
730	return v.GetString()
731}
732
733var xTlsCertificateListNewFromFile func(string, **glib.Error) *glib.List
734
735// Creates one or more #GTlsCertificates from the PEM-encoded
736// data in @file. If @file cannot be read or parsed, the function will
737// return %NULL and set @error. If @file does not contain any
738// PEM-encoded certificates, this will return an empty list and not
739// set @error.
740func TlsCertificateListNewFromFile(FileVar string) (*glib.List, error) {
741	var cerr *glib.Error
742
743	cret := xTlsCertificateListNewFromFile(FileVar, &cerr)
744	if cerr == nil {
745		return cret, nil
746	}
747	return cret, cerr
748
749}
750
751func init() {
752	core.SetPackageName("GIO", "gio-2.0")
753	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
754	var libs []uintptr
755	for _, libPath := range core.GetPaths("GIO") {
756		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
757		if err != nil {
758			panic(err)
759		}
760		libs = append(libs, lib)
761	}
762
763	core.PuregoSafeRegister(&xTlsCertificateGLibType, libs, "g_tls_certificate_get_type")
764
765	core.PuregoSafeRegister(&xNewTlsCertificateFromFile, libs, "g_tls_certificate_new_from_file")
766	core.PuregoSafeRegister(&xNewTlsCertificateFromFileWithPassword, libs, "g_tls_certificate_new_from_file_with_password")
767	core.PuregoSafeRegister(&xNewTlsCertificateFromFiles, libs, "g_tls_certificate_new_from_files")
768	core.PuregoSafeRegister(&xNewTlsCertificateFromPem, libs, "g_tls_certificate_new_from_pem")
769	core.PuregoSafeRegister(&xNewTlsCertificateFromPkcs11Uris, libs, "g_tls_certificate_new_from_pkcs11_uris")
770	core.PuregoSafeRegister(&xNewTlsCertificateFromPkcs12, libs, "g_tls_certificate_new_from_pkcs12")
771
772	core.PuregoSafeRegister(&xTlsCertificateGetDnsNames, libs, "g_tls_certificate_get_dns_names")
773	core.PuregoSafeRegister(&xTlsCertificateGetIpAddresses, libs, "g_tls_certificate_get_ip_addresses")
774	core.PuregoSafeRegister(&xTlsCertificateGetIssuer, libs, "g_tls_certificate_get_issuer")
775	core.PuregoSafeRegister(&xTlsCertificateGetIssuerName, libs, "g_tls_certificate_get_issuer_name")
776	core.PuregoSafeRegister(&xTlsCertificateGetNotValidAfter, libs, "g_tls_certificate_get_not_valid_after")
777	core.PuregoSafeRegister(&xTlsCertificateGetNotValidBefore, libs, "g_tls_certificate_get_not_valid_before")
778	core.PuregoSafeRegister(&xTlsCertificateGetSubjectName, libs, "g_tls_certificate_get_subject_name")
779	core.PuregoSafeRegister(&xTlsCertificateIsSame, libs, "g_tls_certificate_is_same")
780	core.PuregoSafeRegister(&xTlsCertificateVerify, libs, "g_tls_certificate_verify")
781
782	core.PuregoSafeRegister(&xTlsCertificateListNewFromFile, libs, "g_tls_certificate_list_new_from_file")
783
784}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close