Commit ea511460 authored by PhoeniX's avatar PhoeniX

Working SCEP test utility

parent d7f8eeed
......@@ -10,7 +10,7 @@
D0A221551A8CE1B3008F10EF /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A221531A8CE1B3008F10EF /* libcrypto.a */; };
D0A221561A8CE1B3008F10EF /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A221541A8CE1B3008F10EF /* libssl.a */; };
D0BF4AE11A8C81F500F9B8C3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0BF4AE01A8C81F500F9B8C3 /* main.cpp */; };
D0BF4AEE1A8C820900F9B8C3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0BF4AED1A8C820900F9B8C3 /* main.cpp */; };
D0BF4AEE1A8C820900F9B8C3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BF4AED1A8C820900F9B8C3 /* main.m */; };
D0BF4AF91A8D4E2E00F9B8C3 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0BF4AF81A8D4E2E00F9B8C3 /* CoreFoundation.framework */; };
D0BF4AFA1A8D7EBD00F9B8C3 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A221531A8CE1B3008F10EF /* libcrypto.a */; };
D0BF4AFB1A8D7EBF00F9B8C3 /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A221541A8CE1B3008F10EF /* libssl.a */; };
......@@ -48,12 +48,13 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D093E5F11A8E1D49007458AE /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
D0A221531A8CE1B3008F10EF /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = /usr/local/Cellar/openssl/1.0.2/lib/libcrypto.a; sourceTree = "<absolute>"; };
D0A221541A8CE1B3008F10EF /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = /usr/local/Cellar/openssl/1.0.2/lib/libssl.a; sourceTree = "<absolute>"; };
D0BF4ADD1A8C81F500F9B8C3 /* SCEPServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SCEPServer; sourceTree = BUILT_PRODUCTS_DIR; };
D0BF4AE01A8C81F500F9B8C3 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D0BF4AEB1A8C820900F9B8C3 /* SCEPTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SCEPTest; sourceTree = BUILT_PRODUCTS_DIR; };
D0BF4AED1A8C820900F9B8C3 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D0BF4AED1A8C820900F9B8C3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
D0BF4AF81A8D4E2E00F9B8C3 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
......@@ -83,6 +84,7 @@
D0BF4AD41A8C81F500F9B8C3 = {
isa = PBXGroup;
children = (
D093E5F11A8E1D49007458AE /* Security.framework */,
D0BF4AF81A8D4E2E00F9B8C3 /* CoreFoundation.framework */,
D0A221531A8CE1B3008F10EF /* libcrypto.a */,
D0A221541A8CE1B3008F10EF /* libssl.a */,
......@@ -112,7 +114,7 @@
D0BF4AEC1A8C820900F9B8C3 /* SCEPTest */ = {
isa = PBXGroup;
children = (
D0BF4AED1A8C820900F9B8C3 /* main.cpp */,
D0BF4AED1A8C820900F9B8C3 /* main.m */,
);
path = SCEPTest;
sourceTree = "<group>";
......@@ -203,7 +205,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D0BF4AEE1A8C820900F9B8C3 /* main.cpp in Sources */,
D0BF4AEE1A8C820900F9B8C3 /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -222,7 +224,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
......@@ -268,7 +270,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
......
//
// main.cpp
// SCEPTest
//
// Created by Yury Popov on 12.02.15.
// Copyright (c) 2015 PhoeniX. All rights reserved.
//
#include <iostream>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/pem.h>
#include <openssl/asn1.h>
int main(int argc, const char * argv[]) {
EVP_PKEY *key = EVP_PKEY_new();
RSA* rsa = RSA_generate_key(1024, 65537, 0, 0);
EVP_PKEY_assign_RSA(key, rsa);
X509_REQ *req = X509_REQ_new();
X509_REQ_set_version(req, 0);
X509_REQ_set_pubkey(req, key);
X509_NAME *name = X509_NAME_new();
X509_NAME_add_entry_by_NID(name, NID_organizationName, V_ASN1_PRINTABLESTRING, (unsigned char*)"TestFlightApp.com", 17, 0, 0);
X509_NAME_add_entry_by_NID(name, NID_commonName, V_ASN1_PRINTABLESTRING, (unsigned char*)"Tester Cert", 11, 1, 0);
X509_REQ_set_subject_name(req, name);
X509_REQ_add1_attr_by_NID(req, NID_pkcs9_challengePassword, V_ASN1_PRINTABLESTRING, (unsigned char*)"Tester Enrollment Challenge", 27);
STACK_OF(X509_EXTENSION) *stk = new STACK_OF(X509_EXTENSION);
ASN1_OCTET_STRING *s = ASN1_OCTET_STRING_new();
ASN1_OCTET_STRING_set(s, (unsigned char*)"Digital Signature, Key Encipherment", 17+2+16);
X509_EXTENSION *x =
X509_EXTENSION_create_by_NID(NULL, NID_key_usage, 1, s);
stk->stack.num = 1;
stk->stack.num_alloc = 1;
stk->stack.data = (char**)malloc(sizeof(x));
((X509_EXTENSION**)stk->stack.data)[0] = x;
X509_REQ_add_extensions(req, stk);
X509_REQ_sign(req, key, EVP_sha1());
PEM_write_RSAPrivateKey(stdout, rsa, 0, 0, 0, 0, 0);
PEM_write_X509_REQ(stdout, req);
return 0;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment