How to completely script the process of importing SSL certificate and binding this certificate to a specific site - asp.net

I have been looking around for a solution for this problem that works across different versions of Windows Server & IIS, but so far I couldn't find a reasonable solution, what I need is some sort of a script or a command line tool, that takes a certificate file (pfx) for example and then either using the same script or tool find a way to configure one website to use this certificate.

I found a good script on TechNet
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/96ccb49f-b669-4e05-965e-3090984a3594.mspx?mfr=true
CertImport.vbs
Option Explicit
Dim iiscertobj, pfxfile, pfxfilepassword, InstanceName, WebFarmServers, IISServer
Set iiscertobj = WScript.CreateObject("IIS.CertObj")
pfxfile = WScript.Arguments(0)
pfxfilepassword = WScript.Arguments(1)
InstanceName = WScript.Arguments(2)
WebFarmServers = split(WScript.Arguments(3), ",")
iiscertobj.UserName = WScript.Arguments(4)
iiscertobj.UserPassword = WScript.Arguments(5)
For Each IISServer in WebFarmServers
iiscertobj.ServerName = IISServer
iiscertobj.InstanceName = InstanceName
iiscertobj.Import pfxfile, pfxfilepassword, true, true
Next

Related

how to specify "disk=[....]" setting in "xl create" config?

I'm following the wiki https://help.ubuntu.com/community/Xen#Manually_Create_a_PV_Guest_VM
(section "
Set Up Initial Guest Configuration
")
I downloaded the netboot initrd.gz from https://mirror.arizona.edu/ubuntu//ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/xen/
but in the .cfg , what should I specify for the "disk = " line? ---- my host box is not using LVM, so I'll have to use "file-backed storage" for PV disk image. (https://wiki.xenproject.org/wiki/Storage_options , indeed this worked when I gave --dir= instead of --lvm= when running the xml-create command in https://wiki.xenproject.org/wiki/Xen_Project_Beginners_Guide )
here is my current config:
yy#yy-70A4000HUX:~/ub_xen$ cat ub_xen.cfg
name = "ubud1"
kernel = "/home/yy/ub_xen/vmlinuz"
ramdisk = "/home/yy/ub_xen/initrd.gz"
#bootloader = "/usr/lib/xen-4.4/bin/pygrub"
memory = 1024
vcpus = 1
# Custom option for Open vSwitch
vif = [ 'bridge=xenbr0' ]
disk = [ 'vdev=hda,target=/home/yy/ub_xen/images' ]
# You may also consider some other options
# [[http://xenbits.xen.org/docs/4.4-testing/man/xl.cfg.5.html]]
yy#yy-70A4000HUX:~/ub_xen$
I ran the command with sudo xl create -c ub_xen.cfg
this worked fine first, giving me the regular install process on console, pulling install files from remote archive, but when it comes to the step of disk paritioning, it's showing me a "SCSI" partitioning choice, with no volumes / partitions/disks to be chosen.
I guess this is because I'm not setting the right value for "disk = [ ]" option. what should I use here if I use file-backed storage for PV (just like VMware does)?
thanks a lot
Yang
found it, huge thanks to the author here: https://www.systutorials.com/create-and-manage-virtual-machines-on-xen/

Using Jsch ChannelSftp put to a GDG file on mainframe

I'm currently stuck on trying to find a way to put to a generation data group (GDG) on mainframe(zos) using Jsch.
The command line syntax would be
put myFile.txt GDG.MYGDG(+1)
This I know works fine when using sftp or ftp command via a linux shell. I have not found any way to replicate this via the put method of the ChannelSftp class.
I have searched wide and far looking for examples and not found any which makes me think it is not possible with this framework.
Any help would be appreciated.
UPDATE
adding some example code. This is not the full code but shows what I have tried.
String localFileName = localFile.getName();
String remoteFile = "GDG.GDGROUP1(+1)";
FileInputStream inputStream = new FileInputStream(localFile);
ChannelSftp channelSftp = this.getChannelSftp();
String pwd = channelSftp.pwd();
channelSftp.put(inputStream, remoteFile);
The put call always returns that this is directory. I have also tried this for the remote file:
String remoteFile = localFile + " GDG.GDGROUP1(+1)";
This just returns failure.
I have tried absolute path using // and /-/. So far nothing has worked.

Silencing ChromeDriver.exe logging

I am running ruby unit tests against Chrome using watir-webdriver. Whenever a test is run and chromedriver.exe is launched output similar to below appears:
Started ChromeDriver
port=9515
version=26.0.1383.0
log=C:\Home\Server\Test\Watir\web\chromedriver.log
[5468:8796:0404/150755:ERROR:accelerated_surface_win.cc(208)] Reseting D3D device
[5468:8996:0404/150758:ERROR:textfield.h(156)] NOT IMPLEMENTED
[WARNING:..\..\..\..\flash\platform\pepper\pep_module.cpp(63)] SANDBOXED
None of this impacts the correct functioning of the tests, but as one might imagine the appearance of "ERROR" and "WARNING" might be rather confusing to, for example, parsing rules in Jenkins looking for failures. Sure I can get really fancy with regular expression in the parsing rules, but it would be really nice to turn off this verbose and unnecessary logging on the part of chromedriver.exe. I have seen many mentions of this searching for an answer. No one has come up with a solution. Yes, chromedriver possibly has a "--silent" option, but there seems to be no way to pass that to the executable. Code similar to below is supposed to work, but has zero effect as far as I can see. Any ideas?
profile = Selenium::WebDriver::Chrome::Profile.new
profile['--cant-make-any-switches-work-here-how-about-you'] = true
browser = Watir::Browser.new :chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-extensions --disable-popup-blocking --disable-translate--allow-file-access]
Here's help for anyone else searching
Find ...selenium\webdriver\chrome\service.rb
Path start may differ on your system
And I added "-silent" to the passed parameters .... However, this silenced everything but the error/warning messages.
def initialize(executable_path, port)
#uri = URI.parse "http://#{Platform.localhost}:#{port}"
server_command = [executable_path, " -silent", "--port=#{port}"]
#process = ChildProcess.build(*server_command)
#socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT
#process.io.inherit! if $DEBUG == true
end
set chromeOptions with key --log-level=3 this should shut it up
I was able to divert the hundreds, yes hundreds, of chrome driver log messages that were showing up in cucumber stdout by using the :service_log_path argument.
#browser = Watir::Browser.new :chrome, :service_log_path => 'chromedriver.out'
the '-silent', or '--silent', or ' -silent', or ' --silent' parameter suggested above did nothing when I added it to ...selenium\webdriver\chrome\service.rb. And having to tweak the gem itself is not a particularly viable solution.
I couldn't find a place to capture the chromedriver stderr and divert it to null (not to mention having to handle doing that in windows and in *nix/osx)
The driver should default to something way less verbose. In this case INFO is way too verbose as hundreds of log entries pop out as INFO, 90%+ of them identical.
At least the :service_log_path argument works most of them.
You can try -Dwebdriver.chrome.logfile="/dev/null" and/or -Dwebdriver.chrome.args="--disable-logging" to the options of java that runs selenium-server-standalone-what.ever.jar

Escaping parameters passed to perl script within Windows Shell

I have a perl script that was provided by a vendor, and that takes a series of parameters. I would like to call this via a Windows Shell object in ASP classic.
If I type the following in the cmd line on the web server, it works just fine:
path_to_perl\perl.exe path_to_pl\myfile.pl --arg1 "something" --arg2 "somethingelse"
If I do the following in ASP classic, it doesn't work:
strCMD = "path_to_perl\perl.exe path_to_pl\myfile.pl --arg1 ""something"" --arg2 ""somethingelse"""
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("cmd.exe /c " & strCMD)
The issue is that the argument have all sorts of special characters, so I need to quote them. I have read conflicting information as to how I should escape them - via a caret or a back-slash. Any help would be greatly appreciated!
Shoulf call Perl directly, like this:
system_call_test( 'c:/complete/path_to_pl/myfile.pl --arg1 "something" ... ' )
See the discussion here: How to call perl programs from ASP page
and aspecially the answers of Charles K. Clarkson here.
It will simplify the problem, as you will not have to deal with escaping characters
for ASP, CMD and Perl - all at the same time.
(in that discussion the problem was a syntax-error at the Perl-script, eventually,
but it still shows how to code it in ASP).

How do I prevent exposure of my password when using RGoogleDocs?

I love RGoogleDocs and use it a lot. However, I don't like entering my password all the time. Obviously I could just type the password into the R script and would never have to enter it again. But thats not viable since it means that my password would be left unencrypted on my harddrive. Furthermore I share my scripts with colleagues.
To get around the problem I came up with this.
if(exists("ps")){
print("got password, keep going")
} else {
ps <-readline(prompt="get the password in ")
}
options(RCurlOptions = list(
capath = system.file("CurlSSL", "cacert.pem",
package = "RCurl"), ssl.verifypeer = FALSE)
)
sheets.con = getGoogleDocsConnection(
getGoogleAuth("notreal#gmail.com", ps, service ="wise"))
#WARNING: this would prevent curl from detecting a 'man in the middle' attack
ts2=getWorksheets("hpv type",sheets.con)
I love using RStudio. I feel uncomfortable that it is displaying my password for any colleague in my office at the time to see. I used a fake password but look at the image. . Furthermore, if I saved a workspace my password would be saved with it and I am afraid that I would be giving it to someone else if, a few months later, when I had long forgotten about what was in it, I sent my .RData file to a colleague.
I read something general about passwords in R in an earlier post. It did not give me enough information to be able to conceal my password when using RGoogleDocs.
My approach is to set the login-name & password in the R options list
within the R startup file .Rprofile. Then my code gets the value
with getOption() and then the value is never visible or stored
in a top-level variable in globalenv(). (It could be save if
one does post-mortem debugging via dump.frames).
It is vital that the .Rprofile cannot be read by anybody other than you.
So
options(GoogleDocsPassword = c(login = 'password'))
in the .Rprofile and then
auth = getGoogleAuth()
just works as the default value for the first parameter is to look for the GoogleDocsPassword option.
D.
I had the same problem, and no real solution. The workaround I use is, I create a google account just for this purpose, with a password that I do not care about. I then share the documents that I want R to access with that account.
But if someone has an answer to the initial question I am interested as well.
Seems like uou could store the password in your options and the instead of "ps" directly use "getOption". LIkely there are better solutions though.
You could store the password in a file on you computer, encoded and all and call it with somthing like
getPassword <- function(file = location of password file){unencode(readLines(file))}
set this in your .Rprofile and use in the code
getPassword().
This doesn't store your password in any R files and you can build in checks in the file.
If you really don't want to store it anywhere, then one solution to this is not to use a variable for the password, maybe even for the google account address! Building on the linked answer, why not try
library(tcltk)
library(RGoogleDocs)
getHiddenText <- function(label = "Enter text:", symbol = "*", defaultText = ""){
wnd <- tktoplevel()
entryVar <- tclVar(defaultText)
tkgrid(tklabel(wnd, text = label))
#Entry box
tkgrid(entryBox <- tkentry(wnd, textvariable = entryVar, show = symbol))
#Hitting return will also submit text
tkbind(entryBox, "<Return>", function() tkdestroy(wnd))
#OK button
tkgrid(tkbutton(wnd, text="OK", command=function() tkdestroy(wnd)))
#Wait for user to submit
tkwait.window(wnd)
return(tclvalue(entryVar))
}
repeat {
con <- try(getGoogleDocsConnection(getGoogleAuth(
getHiddenText(
label = "Enter google account:",
symbol = "", # or set to "*" to obscure email entry
defaultText = "#gmail.com"), # a little timesaver
getHiddenText(
label = "Enter password:",
symbol = "*",
defaultText = ""),
service = "wise")))
if (inherits(con, "try-error")) {
userResponse <- tkmessageBox(
title = "Error",
message = "Couldn't connect to Google Docs. Try again?",
icon = "error", type = "yesno")
if (tclvalue(userResponse) == "no") {
stop("Unable to connect to Google Docs, user cancelled.")
}
} else { # connection successfully authenticated
break() # so escape the repeat loop
}
}
For things like this I share the google doc with a made up email address, create a google account and then use it for sharing and authorization. Thus, seperating my personal login details from what's necessasry for the script to run.
what about 2 step authentication with application specific password ?
you can use the application specific password without revealing your real one.
and you can revoke it if you want !

Resources