X509_NAME_get_text_by_OBJ function

  1. @RecordUse.new()
  2. @Native<Int Function(Pointer<X509_NAME>, Pointer<ASN1_OBJECT>, Pointer<Char>, Int)>(ffi.Pointer<X509_NAME>, ffi.Pointer<ASN1_OBJECT>, ffi.Pointer<ffi.Char>, ffi.Int)>(symbol: 'bssl_dart_X509_NAME_get_text_by_OBJ')
int X509_NAME_get_text_by_OBJ(
  1. Pointer<X509_NAME> name,
  2. Pointer<ASN1_OBJECT> obj,
  3. Pointer<Char> buf,
  4. int len,
)

X509_NAME_get_text_by_OBJ finds the first attribute with type |obj| in |name|. If found, it writes the value's UTF-8 representation to |buf|. followed by a NUL byte, and returns the number of bytes in the output, excluding the NUL byte. This is unlike OpenSSL which returns the raw ASN1_STRING data. The UTF-8 encoding of the |ASN1_STRING| may not contain a 0 codepoint.

This function writes at most |len| bytes, including the NUL byte. If |buf| is NULL, it writes nothing and returns the number of bytes in the output, excluding the NUL byte that would be required for the full UTF-8 output.

This function may return -1 if an error occurs for any reason, including the value not being a recognized string type, |len| being of insufficient size to hold the full UTF-8 encoding and NUL byte, memory allocation failures, an object with type |obj| not existing in |name|, or if the UTF-8 encoding of the string contains a zero byte.

Implementation

@meta.RecordUse()
@ffi.Native<
  ffi.Int Function(
    ffi.Pointer<X509_NAME>,
    ffi.Pointer<ASN1_OBJECT>,
    ffi.Pointer<ffi.Char>,
    ffi.Int,
  )
>(symbol: 'bssl_dart_X509_NAME_get_text_by_OBJ')
external int X509_NAME_get_text_by_OBJ(
  ffi.Pointer<X509_NAME> name,
  ffi.Pointer<ASN1_OBJECT> obj,
  ffi.Pointer<ffi.Char> buf,
  int len,
);