Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning using Bouncy Castle v.2.3.0 #517

Open
slumdroid opened this issue Feb 5, 2024 · 3 comments
Open

Warning using Bouncy Castle v.2.3.0 #517

slumdroid opened this issue Feb 5, 2024 · 3 comments

Comments

@slumdroid
Copy link

Hello,

using Bouncy Castle v.2.3.0, I have the following warning:
'Asn1TaggedObject.GetObject()' is obsolete: 'Will be removed'

Can you indicate me the new method to use instead it, please?

@slumdroid
Copy link
Author

In this moment, I am trying "Asn1TaggedObject.GetBaseObject()".
And in my first tests, I have not failures.

Is this the correct solution?

@peterdettman
Copy link
Collaborator

A direct drop-in for:

Asn1Object asn1Object = taggedObject.GetObject();

would be:

Asn1Utilities.CheckContextTagClass(taggedObject);
Asn1Object asn1Object = taggedObject.GetBaseObject().ToAsn1Object();

which is basically just inlining the current implementation. CheckContextTagClass can throw, so you might prefer to test taggedObject.HasContextTag() instead.

I would suggest though that you provide a little detail about the call, in particular what your code is expecting to find (i.e. is there a cast or GetInstance call for the return value?) and/or the ASN.1 datatype of which this tagged object is a member (e.g. is it a named type from some RFC?). Direct usage of GetObject() has historically been very error prone in user code.

@slumdroid
Copy link
Author

A direct drop-in for:

Asn1Object asn1Object = taggedObject.GetObject();

would be:

Asn1Utilities.CheckContextTagClass(taggedObject);
Asn1Object asn1Object = taggedObject.GetBaseObject().ToAsn1Object();

which is basically just inlining the current implementation. CheckContextTagClass can throw, so you might prefer to test taggedObject.HasContextTag() instead.

I would suggest though that you provide a little detail about the call, in particular what your code is expecting to find (i.e. is there a cast or GetInstance call for the return value?) and/or the ASN.1 datatype of which this tagged object is a member (e.g. is it a named type from some RFC?). Direct usage of GetObject() has historically been very error prone in user code.

Dear @peterdettman,

thanks for your reply.
I use the cast (Asn1Sequence and Asn1OctectString for different scopes) into my source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants