class OpenSSL::Provider
This class is the access to openssl’s Provider
See also, www.openssl.org/docs/manmaster/man7/provider.html
Public Class Methods
OpenSSL::Provider.load(name) → provider
click to toggle source
This method loads and initializes a provider
static VALUE ossl_provider_s_load(VALUE klass, VALUE name) { OSSL_PROVIDER *provider = NULL; VALUE obj; const char *provider_name_ptr = StringValueCStr(name); provider = OSSL_PROVIDER_load(NULL, provider_name_ptr); if (provider == NULL) { ossl_raise(eProviderError, "Failed to load %s provider", provider_name_ptr); } obj = NewProvider(klass); SetProvider(obj, provider); return obj; }
OpenSSL::Provider.provider_names → [provider_name, ...]
click to toggle source
Returns an array of currently loaded provider names.
static VALUE ossl_provider_s_provider_names(VALUE klass) { VALUE ary = rb_ary_new(); struct ary_with_state cbdata = { ary, 0 }; int result = OSSL_PROVIDER_do_all(NULL, &push_provider, (void*)&cbdata); if (result != 1 ) { if (cbdata.state) { rb_jump_tag(cbdata.state); } else { ossl_raise(eProviderError, "Failed to load provider names"); } } return ary; }
Public Instance Methods
inspect → string
click to toggle source
Pretty prints this provider.
static VALUE ossl_provider_inspect(VALUE self) { OSSL_PROVIDER *prov; if (RTYPEDDATA_DATA(self) == NULL ) { return rb_sprintf("#<%"PRIsVALUE" unloaded provider>", rb_obj_class(self)); } GetProvider(self, prov); return rb_sprintf("#<%"PRIsVALUE" name=\"%s\">", rb_obj_class(self), OSSL_PROVIDER_get0_name(prov)); }
name → string
click to toggle source
Get the name of this provider.
if this provider is already unloaded, it raises OpenSSL::Provider::ProviderError
static VALUE ossl_provider_get_name(VALUE self) { OSSL_PROVIDER *prov; if (RTYPEDDATA_DATA(self) == NULL) { ossl_raise(eProviderError, "Provider already unloaded."); } GetProvider(self, prov); return rb_str_new2(OSSL_PROVIDER_get0_name(prov)); }
unload → true
click to toggle source
This method unloads this provider.
if provider unload fails or already unloaded, it raises OpenSSL::Provider::ProviderError
static VALUE ossl_provider_unload(VALUE self) { OSSL_PROVIDER *prov; if (RTYPEDDATA_DATA(self) == NULL) { ossl_raise(eProviderError, "Provider already unloaded."); } GetProvider(self, prov); int result = OSSL_PROVIDER_unload(prov); if (result != 1) { ossl_raise(eProviderError, "Failed to unload provider"); } RTYPEDDATA_DATA(self) = NULL; return Qtrue; }