mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Add mkcom functionality to zerotier-idtool for use by new NodeJS netconf-master code.
This commit is contained in:
parent
0ba0c6d04d
commit
08da4b8c7b
1 changed files with 29 additions and 0 deletions
29
main.cpp
29
main.cpp
|
@ -62,6 +62,7 @@
|
||||||
#include "node/C25519.hpp"
|
#include "node/C25519.hpp"
|
||||||
#include "node/Identity.hpp"
|
#include "node/Identity.hpp"
|
||||||
#include "node/Thread.hpp"
|
#include "node/Thread.hpp"
|
||||||
|
#include "node/CertificateOfMembership.hpp"
|
||||||
|
|
||||||
using namespace ZeroTier;
|
using namespace ZeroTier;
|
||||||
|
|
||||||
|
@ -314,6 +315,34 @@ static int main(int argc,char **argv)
|
||||||
fprintf(stderr,"%s signature check FAILED"ZT_EOL_S,argv[3]);
|
fprintf(stderr,"%s signature check FAILED"ZT_EOL_S,argv[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
} else if (!strcmp(argv[1],"mkcom")) {
|
||||||
|
if (argc < 3) {
|
||||||
|
printHelp(stdout,argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Identity id = getIdFromArg(argv[2]);
|
||||||
|
if ((!id)||(!id.hasPrivate())) {
|
||||||
|
fprintf(stderr,"Identity argument invalid, does not include private key, or file unreadable: %s"ZT_EOL_S,argv[2]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CertificateOfMembership com;
|
||||||
|
for(int a=3;a<argc;++a) {
|
||||||
|
std::vector<std::string> params(Utils::split(argv[a],",","",""));
|
||||||
|
if (params.size() == 3) {
|
||||||
|
uint64_t qId = Utils::hexStrToU64(params[0].c_str());
|
||||||
|
uint64_t qValue = Utils::hexStrToU64(params[1].c_str());
|
||||||
|
uint64_t qMaxDelta = Utils::hexStrToU64(params[2].c_str());
|
||||||
|
com.setQualifier(qId,qValue,qMaxDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!com.sign(id)) {
|
||||||
|
fprintf(stderr,"Signature of certificate of membership failed."ZT_EOL_S);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s",com.toString().c_str());
|
||||||
} else {
|
} else {
|
||||||
printHelp(stdout,argv[0]);
|
printHelp(stdout,argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue