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

Read, Write, Execute method of Security object in leshan-client-demo was not called after a bootstrap #522

Closed
chuchiliusandc opened this issue Jun 13, 2018 · 4 comments
Labels
bug Dysfunctionnal behavior client Impact LWM2M client demo Impact our demo (not libraries)

Comments

@chuchiliusandc
Copy link

Hi,

I am confused here.
I populated the certificate in leshan-server-bs and respond according to bootstrap request ...
However, the leshan-client-sim's Security object constructor, read, write methods are not triggered.
Does leshan-client-sim really save the certificate ?

Thanks :)

@sbernard31
Copy link
Contributor

What do you call leshan-server-sim ? I suppose you are talking about leshan-server-demo.

Anyway for now Leshan does not really support X509(#436) and RPK(#435) at client side, but write method in Security object should be triggered...

@sbernard31 sbernard31 added the question Any question about leshan label Jun 13, 2018
@chuchiliusandc
Copy link
Author

chuchiliusandc commented Jun 13, 2018

write is not being called since i add log in the method. Can you check on your side ?

Also, there seems to be a bug. Both write cases below tried to set secret key ...

    case SEC_SERVER_PUBKEY: // server public key
        if (value.getType() != Type.OPAQUE) {
            return WriteResponse.badRequest("invalid type");
        }
        secretKey = (byte[]) value.getValue();
        LOG.info("serverPublicKey    : " + Arrays.toString(serverPublicKey)    );
        return WriteResponse.success();
    case SEC_SECRET_KEY: // Secret Key
        if (value.getType() != Type.OPAQUE) {
            return WriteResponse.badRequest("invalid type");
        }
        secretKey = (byte[]) value.getValue();
        LOG.info("secretKey          : " + Arrays.toString(secretKey)          );
        return WriteResponse.success();

@sbernard31
Copy link
Contributor

@chuchiliusandc, good catch about the variable issue.

And you're right too about this method was never called after a bootstrap.

That was because a SimpleInstanceEnabler was created instead of Security object.

Explanation:
Via initializer, you can create a factory for each object to make leshan-client able to create new instance. To do that you can use setFactoryForObject or setClassForObject (in this case the class should have an empty constructor and the factory will just call it) or setInstancesForObject.

For the last method this set the initial instances and create a factory which use the default/empty constructor of the class of the instance or a dummy factory which will create dummy SimpleInstanceEnabler.

At bootstrap time, initial instance of Security and Server was deleted, then new instance was created. As Server/Security does not have default empty constructor, a SimpleInstanceEnabler was used. (you could check this by adding logs in this class)

I fixed those 2 issue in #523. You could check if this behave better now.
But anyway X509 support at client side is still not implemented :/

@sbernard31 sbernard31 added bug Dysfunctionnal behavior client Impact LWM2M client demo Impact our demo (not libraries) and removed question Any question about leshan labels Jun 14, 2018
@sbernard31 sbernard31 changed the title [leshan-server-bs] trying to send certificate to leshan-client-sim, but not trigger break point in Security object constructor, read, or even write method ... Read, Write, Execute method of Security object in leshan-client-demo was not called after a bootstrap Jun 14, 2018
@chuchiliusandc
Copy link
Author

Got it. Thanks @sbernard31 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Dysfunctionnal behavior client Impact LWM2M client demo Impact our demo (not libraries)
Projects
None yet
Development

No branches or pull requests

2 participants