Skip to content

Commit

Permalink
Version 0.9.0, added IPv6 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Nov 6, 2020
1 parent 7104636 commit f4d0aa8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26,896 deletions.
4 changes: 2 additions & 2 deletions amt-certificates-0.0.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function amtcert_linkCertPrivateKey(certs, keys) {
for (var i in certs) {
var cert = certs[i];
try {
if (xxCertPrivateKeys.length == 0) return;
if (keys.length == 0) return;
var publicKeyPEM = forge.pki.publicKeyToPem(forge.pki.certificateFromAsn1(forge.asn1.fromDer(cert.X509Certificate)).publicKey).substring(28 + 32).replace(/(\r\n|\n|\r)/gm, "");
for (var j = 0; j < keys.length; j++) {
if (publicKeyPEM === (keys[j]['DERKey'] + '-----END PUBLIC KEY-----')) {
Expand Down Expand Up @@ -102,7 +102,7 @@ function amtcert_createCertificate(certAttributes, caPrivateKey, DERKey, issuerA
cert.setIssuer(attrs);
}

if (caPrivateKey == undefined) {
if (caPrivateKey == null) {
// Create a root certificate
cert.setExtensions([{
name: 'basicConstraints',
Expand Down
2 changes: 1 addition & 1 deletion amt-wsman-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var WsmanStackCreateService = function (host, port, user, pass, tls, extra) {
if (namespaces == null) namespaces = '';
obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
var wsresponse = obj.ParseWsman(data);
if ((data != null) && (!wsresponse || wsresponse == null)) {
if ((data != null) && (!wsresponse || wsresponse == null) && (status == 200)) {
callback(obj, null, { Header: { HttpError: status } }, 601, tag);
} else {
if (status != 200) {
Expand Down
6 changes: 3 additions & 3 deletions amt-wsman-ws-0.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var CreateWsmanComm = function (host, port, user, pass, tls) {
obj.pass = pass;
obj.tls = tls;
obj.tlsv1only = 0;
obj.cnonce = Math.random().toString(36).substring(7); // Generate a random client nonce
obj.inDataCount = 0;
obj.amtVersion = null;
obj.digestRealmMatch = null;
Expand Down Expand Up @@ -98,8 +97,9 @@ var CreateWsmanComm = function (host, port, user, pass, tls) {
obj.CancelAllQueries(997);
return;
}
var response = hex_md5(hex_md5(obj.user + ':' + obj.challengeParams['realm'] + ':' + obj.pass) + ':' + obj.challengeParams['nonce'] + ':' + obj.noncecounter + ':' + obj.cnonce + ':' + obj.challengeParams['qop'] + ':' + hex_md5(action + ':' + url + ((obj.challengeParams['qop'] == 'auth-int') ? (':' + hex_md5(postdata)) : '')));
h += 'Authorization: ' + obj.renderDigest({ 'username': obj.user, 'realm': obj.challengeParams['realm'], 'nonce': obj.challengeParams['nonce'], 'uri': url, 'qop': obj.challengeParams['qop'], 'response': response, 'nc': obj.noncecounter++, 'cnonce': obj.cnonce }) + '\r\n';
var cnonce = Math.random().toString(36).substring(7); // Generate a random client nonce
var response = hex_md5(hex_md5(obj.user + ':' + obj.challengeParams['realm'] + ':' + obj.pass) + ':' + obj.challengeParams['nonce'] + ':' + obj.noncecounter + ':' + cnonce + ':' + obj.challengeParams['qop'] + ':' + hex_md5(action + ':' + url + ((obj.challengeParams['qop'] == 'auth-int') ? (':' + hex_md5(postdata)) : '')));
h += 'Authorization: ' + obj.renderDigest({ 'username': obj.user, 'realm': obj.challengeParams['realm'], 'nonce': obj.challengeParams['nonce'], 'uri': url, 'qop': obj.challengeParams['qop'], 'response': response, 'nc': obj.noncecounter++, 'cnonce': cnonce }) + '\r\n';
}
h += 'Host: ' + obj.host + ':' + obj.port + '\r\nContent-Length: ' + postdata.length + '\r\n\r\n' + postdata; // Use Content-Length
//h += 'Host: ' + obj.host + ':' + obj.port + '\r\nTransfer-Encoding: chunked\r\n\r\n' + postdata.length.toString(16).toUpperCase() + '\r\n' + postdata + '\r\n0\r\n\r\n'; // Use Chunked-Encoding
Expand Down
Loading

0 comments on commit f4d0aa8

Please sign in to comment.