Skip to content

Instantly share code, notes, and snippets.

View vicneanschi's full-sized avatar

Valeri Vicneanschi vicneanschi

  • Montreal, Canada
View GitHub Profile
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
string a = Console.ReadLine();
string b = Console.ReadLine();
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
string[] tokens_n = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(tokens_n[0]);
int k = Convert.ToInt32(tokens_n[1]);
@vicneanschi
vicneanschi / openssl.sh
Last active July 6, 2016 19:14
openssl
openssl s_client -state -connect powhatan.iiie.disa.mil:443 -CAfile dodrootca2_new.cer -cert client.crt -key client.key
GET / HTTP/1.1
Host: powhatan.iiie.disa.mil
subject=/C=US/O=U.S. Government/OU=DoD/OU=PKI/CN=DOD CA-27
issuer=/C=US/O=U.S. Government/OU=DoD/OU=PKI/CN=DoD Root CA 2
-----BEGIN CERTIFICATE-----
MIIFTDCCBDSgAwIBAgICAbIwDQYJKoZIhvcNAQEFBQAwWzELMAkGA1UEBhMCVVMx
GDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDEMMAoGA1UECxMDRG9EMQwwCgYDVQQL
EwNQS0kxFjAUBgNVBAMTDURvRCBSb290IENBIDIwHhcNMTEwOTA4MTU1MDI1WhcN
MTcwOTA4MTU1MDI1WjBXMQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zl
cm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsTA1BLSTESMBAGA1UEAxMJRE9E
IENBLTI3MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAloQI/Xq6tpSD
0J07GQvPBN+IKp64GljrhyIqYzp/OcNra+e8GqgRAvVhzQGkmHVzxheMiTxCx+KO
If you enable ssl in apache, you can verify a client certificate.
If so apache will create a environment variable for you with the name 'SSL_CLIENT_VERIFY' with values 'NONE, SUCCESS, GENEROUS or FAILED:reason'.
See https://httpd.apache.org/docs/2.0/mod/mod_ssl.html
NONE: client has no cert
SUCCESS = cert is valid
GENEROUS = says only that some kind of certificate was sent at all
FAILED:reason = auth with the cert failed
subject=/C=US/O=U.S. Government/OU=ECA/CN=ECA Root CA
issuer=/C=US/O=U.S. Government/OU=ECA/CN=ECA Root CA
-----BEGIN CERTIFICATE-----
MIICmDCCAgGgAwIBAgIBDjANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJVUzEY
MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNFQ0ExFDASBgNVBAMT
C0VDQSBSb290IENBMB4XDTA0MDYxNDEwMjAwOVoXDTQwMDYxNDEwMjAwOVowSzEL
MAkGA1UEBhMCVVMxGDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDEMMAoGA1UECxMD
RUNBMRQwEgYDVQQDEwtFQ0EgUm9vdCBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEArkr2eXIS6oAKIpDkOlcQZdMGdncoygCEIU+ktqY3of5SVVXU7/it7kJ1
EUzR4ii2vthQtbww9aAnpQxcEmXZk8eEyiGEPy+cCQMllBY+efOtKgjbQNDZ3lB9
#!/bin/bash
#
# Retrieves DoD root certificates, converts them to PEM
# format, and concatenates them into one big PEM file.
#
# @author DMcG
if [-d rootCerts]; then
rm -rf rootCerts
fi
@vicneanschi
vicneanschi / ssl.conf
Created June 15, 2016 14:15
Apache ssl.conf for CAC user authentication
[root@localhost ~]# cat /etc/httpd/conf.d/ssl.conf
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these
# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
@vicneanschi
vicneanschi / Install.txt
Created May 26, 2016 21:01
docker toolbox chocolatey test
C:\Users\VALVI\projects\github\chocolatey-test-environment>vagrant provision
==> default: Running provisioner: shell...
default: Running: shell/PrepareWindows.ps1 as c:\tmp\vagrant-shell.ps1
==> default: IE Enhanced Security Configuration (ESC) has been disabled.
==> default:
==> default: IE first run welcome screen has been disabled.
==> default: Setting Windows Update service to Manual startup type.
==> default: Running provisioner: shell...
default: Running: shell/InstallNet4.ps1 as c:\tmp\vagrant-shell.ps1
==> default: Running provisioner: shell...
// https://www.hackerrank.com/challenges/maximise-sum
function processData(input) {
var lines = input.split('\n')
var line = 0;
var t = parseInt(lines[line++]);
for (var i = 0; i < t; i++){
var tmp = lines[line++].split(' ').map(x => parseInt(x));
var n = tmp[0], m = tmp[1];
var arr = lines[line++].split(' ').map(x => parseInt(x)).slice(0, n);