Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

How to get mulitiple certificates from the applet

JavaCard Applet Development Related Questions and Answers.
Vlidda
Posts: 16
Joined: Tue Sep 06, 2016 2:59 am
Points :196
Contact:

How to get mulitiple certificates from the applet

Post by Vlidda » Fri May 26, 2017 11:23 pm

Hey guys ,

I need to store certificate on the card. And I know that I can use the instruction of GET_DATA to get the user certificate.

Code: Select all

public void process(APDU apdu)
{
byte[] buf = apdu.getBuffer();
...
case INS_GET_DATA:
...
case INS_GET_RESPONSE:
sendCertificate( apdu );

break;
}


Now I want to store multiple certificates on the card. And I still have to retrieve them. How can I do that? Please give me some pieces of guidance.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: How to get mulitiple certificates from the applet

Post by mabel » Sat May 27, 2017 5:31 am

To solve your problem, you can use tags : 0x0100 for cert1, 0x0101 for cert2, 0x0102 for cert3.

These would be passed in to PUT DATA and GET DATA to indicate which certificate is required.
Then you can retrieve any cert according to your need.

Vlidda
Posts: 16
Joined: Tue Sep 06, 2016 2:59 am
Points :196
Contact:

Re: How to get mulitiple certificates from the applet

Post by Vlidda » Sat May 27, 2017 6:02 am

Thanks for your suggestion. I will have a try.

tay00000
Posts: 161
Joined: Tue Sep 27, 2016 10:58 am
Points :2324
Contact:

Re: How to get mulitiple certificates from the applet

Post by tay00000 » Sun May 28, 2017 2:51 am

I will try to go to enough details without turning this into a spoon-feeding session.

Create a class object called Certificate. This Certificate class will store a certAlias in byte[] object which you can allocate probably 10 bytes to use as certAlias as well as a certObject in byte[] object with probably about 2500 bytes or as much bytes as needed to store a certificate object in bytes and a short object called certSize which will be the size of the certObject in short representation.

Then in the main applet class, during initialization of card applet, you can store an array of Certificate object in the form of Certificate[] certList = new Certificate[(short) 5]; to indicate capacity to store a maximum of 5 certificate objects within the card.

You will at least need these methods to be able to handle multiple certificate:
- List how many certificate objects are being used.
- List all the certAlias objects.
- Select a particular certificate to read it's binary certificate via it's certAlias handle.
- Ensure certAlias is unique between all the objects.

If this is too complex for you, that means you have to sit down and re-prioritize and re-evaluate the necessity of storing so many certificate objects inside an applet in the first place as most typical use case will only require storing a single certificate that matches the card's private key. It is highly advisable to avoid the complexities of storing and managing more than 1 certificate as the complexity can introduce bugs into your applet codes unless you are very clear on what you are doing and can handle complex scenarios in tight spaces presented during applet development and deployment.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: How to get mulitiple certificates from the applet

Post by UNKNwYSHSA » Sun May 28, 2017 11:01 pm

Vlidda wrote:Hey guys ,

I need to store certificate on the card. And I know that I can use the instruction of GET_DATA to get the user certificate.

Code: Select all

public void process(APDU apdu)
{
byte[] buf = apdu.getBuffer();
...
case INS_GET_DATA:
...
case INS_GET_RESPONSE:
sendCertificate( apdu );

break;
}


Now I want to store multiple certificates on the card. And I still have to retrieve them. How can I do that? Please give me some pieces of guidance.


Your requirement is like the PKI applet.
You can refer to the opensource PKI applet, and it is used with PKI middleware.
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 15 guests

JavaCard OS : Disclaimer