hierynomus / sshj

ssh, scp and sftp for java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion for public key to be null makes no sense

lfmunoz opened this issue · comments

My code:

 val keyProvider = ssh.loadKeys(config.privateKey, config.publicKey, null)

Error:

java.lang.AssertionError
	at net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider.init(BaseFileKeyProvider.java:62)
	at net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider.init(BaseFileKeyProvider.java:68)
	at net.schmizz.sshj.SSHClient.loadKeys(SSHClient.java:622)

Code that produces error:

package net.schmizz.sshj.userauth.keyprovider;

    @Override
    public void init(String privateKey, String publicKey) {
        assert privateKey != null;
        assert publicKey == null;    // <------------------------------------ why does it matter if it is null?
        resource = new PrivateKeyStringResource(privateKey);

Why is there an assertions for publickey to be null?