Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
495f89a0
Unverified
Commit
495f89a0
authored
Sep 24, 2020
by
honfika
Committed by
GitHub
Sep 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #795 from keyoti/FixIPAddressCerts
Fix ip address certs
parents
a3879250
3f19596d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
6 deletions
+62
-6
Capture.PNG
examples/Titanium.Web.Proxy.Examples.Basic/Capture.PNG
+0
-0
BCCertificateMaker.cs
src/Titanium.Web.Proxy/Certificates/BCCertificateMaker.cs
+7
-1
WinCertificateMaker.cs
src/Titanium.Web.Proxy/Certificates/WinCertificateMaker.cs
+55
-5
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/Capture.PNG
deleted
100644 → 0
View file @
a3879250
51.5 KB
src/Titanium.Web.Proxy/Certificates/BCCertificateMaker.cs
View file @
495f89a0
using
System
;
using
System.IO
;
using
System.Net
;
using
System.Security.Cryptography.X509Certificates
;
using
Org.BouncyCastle.Asn1
;
using
Org.BouncyCastle.Asn1.Pkcs
;
...
...
@@ -96,7 +97,12 @@ namespace Titanium.Web.Proxy.Network.Certificate
if
(
hostName
!=
null
)
{
// add subject alternative names
var
subjectAlternativeNames
=
new
Asn1Encodable
[]
{
new
GeneralName
(
GeneralName
.
DnsName
,
hostName
)
};
var
nameType
=
GeneralName
.
DnsName
;
if
(
IPAddress
.
TryParse
(
hostName
,
out
_
))
{
nameType
=
GeneralName
.
IPAddress
;
}
var
subjectAlternativeNames
=
new
Asn1Encodable
[]
{
new
GeneralName
(
nameType
,
hostName
)
};
var
subjectAlternativeNamesExtension
=
new
DerSequence
(
subjectAlternativeNames
);
certificateGenerator
.
AddExtension
(
X509Extensions
.
SubjectAlternativeName
.
Id
,
false
,
...
...
src/Titanium.Web.Proxy/Certificates/WinCertificateMaker.cs
View file @
495f89a0
using
System
;
using
System.Net
;
using
System.Reflection
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Threading
;
...
...
@@ -220,11 +221,20 @@ namespace Titanium.Web.Proxy.Network.Certificate
var
altNameCollection
=
Activator
.
CreateInstance
(
typeAltNamesCollection
);
var
extNames
=
Activator
.
CreateInstance
(
typeExtNames
);
var
altDnsNames
=
Activator
.
CreateInstance
(
typeCAlternativeName
);
typeValue
=
new
object
[]
{
3
,
subject
};
typeCAlternativeName
.
InvokeMember
(
"InitializeFromString"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
var
altDnsNames
=
Activator
.
CreateInstance
(
typeCAlternativeName
);
IPAddress
ip
;
if
(
IPAddress
.
TryParse
(
subject
,
out
ip
))
{
String
ipBase64
=
Convert
.
ToBase64String
(
ip
.
GetAddressBytes
());
typeValue
=
new
object
[]
{
AlternativeNameType
.
XCN_CERT_ALT_NAME_IP_ADDRESS
,
EncodingType
.
XCN_CRYPT_STRING_BASE64
,
ipBase64
};
typeCAlternativeName
.
InvokeMember
(
"InitializeFromRawData"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
}
else
{
typeValue
=
new
object
[]
{
3
,
subject
};
//3==DNS, 8==IP ADDR
typeCAlternativeName
.
InvokeMember
(
"InitializeFromString"
,
BindingFlags
.
InvokeMethod
,
null
,
altDnsNames
,
typeValue
);
}
typeValue
=
new
[]
{
altDnsNames
};
typeAltNamesCollection
.
InvokeMember
(
"Add"
,
BindingFlags
.
InvokeMethod
,
null
,
altNameCollection
,
...
...
@@ -298,5 +308,45 @@ namespace Titanium.Web.Proxy.Network.Certificate
return
new
X509Certificate2
(
Convert
.
FromBase64String
(
empty
),
string
.
Empty
,
X509KeyStorageFlags
.
Exportable
);
}
}
public
enum
EncodingType
{
XCN_CRYPT_STRING_ANY
=
7
,
XCN_CRYPT_STRING_BASE64
=
1
,
XCN_CRYPT_STRING_BASE64_ANY
=
6
,
XCN_CRYPT_STRING_BASE64HEADER
=
0
,
XCN_CRYPT_STRING_BASE64REQUESTHEADER
=
3
,
XCN_CRYPT_STRING_BASE64URI
=
13
,
XCN_CRYPT_STRING_BASE64X509CRLHEADER
=
9
,
XCN_CRYPT_STRING_BINARY
=
2
,
XCN_CRYPT_STRING_CHAIN
=
0x100
,
XCN_CRYPT_STRING_ENCODEMASK
=
0xff
,
XCN_CRYPT_STRING_HASHDATA
=
0x10000000
,
XCN_CRYPT_STRING_HEX
=
4
,
XCN_CRYPT_STRING_HEX_ANY
=
8
,
XCN_CRYPT_STRING_HEXADDR
=
10
,
XCN_CRYPT_STRING_HEXASCII
=
5
,
XCN_CRYPT_STRING_HEXASCIIADDR
=
11
,
XCN_CRYPT_STRING_HEXRAW
=
12
,
XCN_CRYPT_STRING_NOCR
=
-
2147483648
,
XCN_CRYPT_STRING_NOCRLF
=
0x40000000
,
XCN_CRYPT_STRING_PERCENTESCAPE
=
0x8000000
,
XCN_CRYPT_STRING_STRICT
=
0x20000000
,
XCN_CRYPT_STRING_TEXT
=
0x200
}
public
enum
AlternativeNameType
{
XCN_CERT_ALT_NAME_DIRECTORY_NAME
=
5
,
XCN_CERT_ALT_NAME_DNS_NAME
=
3
,
XCN_CERT_ALT_NAME_GUID
=
10
,
XCN_CERT_ALT_NAME_IP_ADDRESS
=
8
,
XCN_CERT_ALT_NAME_OTHER_NAME
=
1
,
XCN_CERT_ALT_NAME_REGISTERED_ID
=
9
,
XCN_CERT_ALT_NAME_RFC822_NAME
=
2
,
XCN_CERT_ALT_NAME_UNKNOWN
=
0
,
XCN_CERT_ALT_NAME_URL
=
7
,
XCN_CERT_ALT_NAME_USER_PRINCIPLE_NAME
=
11
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment