S2I_ASN1_IA5STRING(3ossl)

✨ S2I_ASN1_IA5STRING ✨

okay bestie, welcome to the OpenSSL corner of the manual, section 3ossl. this page is literally about converting objects back and forth between their ASN.1 selves and their string selves. it's giving translator energy πŸ’…


🌸 NAME 🌸

no cap, this page covers a whole lil squad of functions:

  • i2s_ASN1_IA5STRING
  • s2i_ASN1_IA5STRING
  • i2s_ASN1_INTEGER
  • s2i_ASN1_INTEGER
  • i2s_ASN1_OCTET_STRING
  • s2i_ASN1_OCTET_STRING
  • i2s_ASN1_ENUMERATED
  • i2s_ASN1_ENUMERATED_TABLE
  • i2s_ASN1_UTF8STRING
  • s2i_ASN1_UTF8STRING

and what do they all do? they convert objects from/to ASN.1/string representation. periodt.


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/x509v3.h>

char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);
ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
                                  X509V3_CTX *ctx, const char *str);
char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a);
ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, const char *value);
char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
                           const ASN1_OCTET_STRING *oct);
ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
                                        X509V3_CTX *ctx, const char *str);
char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *a);
char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method,
                               const ASN1_ENUMERATED *e);

char *i2s_ASN1_UTF8STRING(X509V3_EXT_METHOD *method,
                          ASN1_UTF8STRING *utf8);
ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method,
                                     X509V3_CTX *ctx, const char *str);

like, that's the whole lineup, go off πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: these functions convert OpenSSL objects to and from their ASN.1/string representation. and who's using them? X509v3 extensions, that's who. it's their whole moment. πŸ”₯


πŸ’œ NOTES πŸ’œ

okay so the letters i and s in i2s and s2i stand for "internal" (aka an internal C structure) and string respectively. so i2s_ASN1_IA5STRING() converts from internal to string. iykyk πŸ’–

and this part matters, bestie: it is the caller's responsibility to free the returned string. in the i2s_ASN1_IA5STRING() function the string is copied and the ownership of the original string remains with the caller. so don't be out here freeing stuff you don't own, that's not the vibe 😭

⭐ RETURN VALUES ⭐

one by one, no skipping, we love a thorough queen:

  • i2s_ASN1_IA5STRING() β€” returns the pointer to a IA5 string or NULL if an error occurs.
  • s2i_ASN1_IA5STRING() β€” return a valid ASN1_IA5STRING structure or NULL if an error occurs.
  • i2s_ASN1_INTEGER() β€” return a valid string or NULL if an error occurs.
  • s2i_ASN1_INTEGER() β€” returns the pointer to a ASN1_INTEGER structure or NULL if an error occurs.
  • i2s_ASN1_OCTET_STRING() β€” returns the pointer to a OCTET_STRING string or NULL if an error occurs.
  • s2i_ASN1_OCTET_STRING() β€” return a valid ASN1_OCTET_STRING structure or NULL if an error occurs.
  • i2s_ASN1_ENUMERATED() β€” return a valid string or NULL if an error occurs.
  • s2i_ASN1_ENUMERATED() β€” returns the pointer to a ASN1_ENUMERATED structure or NULL if an error occurs.
  • s2i_ASN1_UTF8STRING() β€” return a valid ASN1_UTF8STRING structure or NULL if an error occurs.
  • i2s_ASN1_UTF8STRING() β€” returns the pointer to a UTF-8 string or NULL if an error occurs.

the way it's NULL on error every single time... consistent icon behavior, we stan 🫢


🌈 HISTORY 🌈

i2s_ASN1_UTF8STRING() and s2i_ASN1_UTF8STRING() were made public in OpenSSL 3.0. glow up fr fr ✨


Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.

okay that link right there? that's the only link this page gets, and it's staying, because rules are rules πŸ’…

and that's a wrap, bestie πŸŽ€ this page was served to you from version 3.5.9, dated 2026-09-29, and its whole manual name is S2I_ASN1_IA5STRING(3ossl). go forth and convert responsibly πŸŒΈπŸ¦‹πŸ’–

πŸ“¦ where this page comes from