Search results

There are no results.

std.crypto.x509.Certificate

type pub inline Certificate

An X.509 certificate.

This is currently just an opaque wrapper around a ByteArray.

Static methods

from_pem_file

Show source code
Hide source code
fn pub static from_pem_file(
  path: ref Path,
) -> Result[Certificate, ParseError] {
  let file = match ReadOnlyFile.new(path) {
    case Ok(v) -> pem.PemFile.new(v)
    case Error(e) -> throw ParseError.Read(e)
  }

  match file.next_certificate {
    case Ok(Some(v)) -> Result.Ok(v)
    case Ok(None) -> Result.Error(ParseError.Missing)
    case Error(e) -> Result.Error(ParseError.Invalid(e))
  }
}
fn pub static from_pem_file(path: ref Path) -> Result[Certificate, ParseError]

Parses the first certificate from a PEM file.

For more control over the parsing of PEM files, use std.crypto.pem.PemFile directly.

Errors

If the file is invalid or no certificate is found, a ParseError error is returned.

Examples

import std.crypto.x509

Certificate.from_pem_file('cacert.pem').or_panic # => Result.Ok(Certificate(...))

new

Show source code
Hide source code
fn pub inline static new(bytes: ByteArray) -> Certificate {
  Certificate(bytes)
}
fn pub inline static new(bytes: ByteArray) -> Certificate

Returns a new Certificate that wraps the given ByteArray.

Instance methods

!=

Show source code
Hide source code
fn pub !=(other: ref Self) -> Bool {
  !(self == other)
}
fn pub !=(other: ref Self) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide source code
fn pub ==(other: ref Certificate) -> Bool {
  @bytes == other.bytes
}
fn pub ==(other: ref Certificate) -> Bool

Returns true if self and the given object are equal to each other.

This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.

fmt

Show source code
Hide source code
fn pub fmt(formatter: mut Formatter) {
  formatter.write('Certificate(${@bytes.size} bytes)')
}
fn pub fmt(formatter: mut Formatter)

Formats self in a human-readable format for debugging purposes.

Implemented traits

std.cmp.

Equal

impl Equal for Certificate
std.fmt.

Format

impl Format for Certificate