From: GOTOU Yuuzou Date: 2005-04-08T17:24:41+09:00 Subject: Re: Ruby ASN1 examples? Hi, In message <20050407211440.GA676@uk.tiscali.com>, `Brian Candler ' wrote: > But a tagged instance of a tagged type is tricky. The only way I could > figure out was: > > date = OpenSSL::ASN1::ISO64String("19710917", 3, :IMPLICIT, :APPLICATION) > date2 = OpenSSL::ASN1::ASN1Data.new([date], 1, :CONTEXT_SPECIFIC) > p date2.to_der # => A1 0A 43 08 "19710917" > > ext/openssl/ossl_asn1.c claims to be written by "'OpenSSL for Ruby' team > members" - are there any of them here who would care to comment? Is there an > easier way to achieve this? Hmm, I have never been careful about tagged instance of tagged types. It seems that this problem appers within making explicit tagged instance of tagged types. If this premise is right and to_der method is modified to refer user defined default tag, inheriting primitive types may make it easy. A conceptual usage is as follows: # define new class to overrides ISO64Strings's tag number # and tag class. class X690Date < OpenSSL::ASN1::ISO64String DEFAULT_TAG = 3 DEFAULT_TAG_CLASS = :APPLICATION end X690Date.new("19710917", 1, :EXPLICIT, :CONTEXT_SPECIFIC).to_der any ideas? -- gotoyuzo