I am trying to create a .NET application in F# that calls out to the Jira REST API to read/create issues.
I generated a .pub and .pem with OpenSSL, and created an application link in Jira with the public key.
Here is the signing function that I put together (based off of some C# code I found in a blog post) that gets me the initial token response:
let rsasha1 (signingKey : string) str =
let rsa = new RSACryptoServiceProvider()
rsa.FromXmlString(signingKey)
let shaHashObject = new SHA1Managed()
let data = Encoding.ASCII.GetBytes(str : string)
let hash = shaHashObject.ComputeHash(data)
let signedValue = rsa.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"))
Convert.ToBase64String(signedValue, Base64FormattingOptions.None)
And this is the function that I'm using to do the call (also found from a snippet online)
/// Request a token and return:
/// oauth_token, oauth_token_secret, oauth_callback_confirmed
let requestToken() =
let queryParameters =
["oauth_callback", "oob"
"oauth_consumer_key", consumerKey
"oauth_nonce", System.Guid.NewGuid().ToString().Substring(24)
"oauth_signature_method", "RSA-SHA1"
"oauth_timestamp", currentUnixTime().ToString()
"oauth_version", "1.0"]
let signingString = baseString "POST" requestTokenURI queryParameters
let rsaSignature = rsasha1 consumerSecretXML signingString
let realQueryParameters = ("oauth_signature", rsaSignature)::queryParameters
let req = WebRequest.Create(requestTokenURI, Method="POST")
let headerValue = createAuthorizeHeader realQueryParameters
req.Headers.Add(HttpRequestHeader.Authorization, headerValue)
let resp = req.GetResponse()
let stream = resp.GetResponseStream()
let txt = (new StreamReader(stream)).ReadToEnd()
let parts = txt.Split('&')
(parts.[0].Split('=').[1],
parts.[1].Split('=').[1],
parts.[2].Split('=').[1] = "true")
This successfully returns token information, but I am unsure what to do next once I have the token. The original C# code that I based this off of was using HMACSHA1 instead of RSASHA1 and simply concatenated the consumer secret with the token secret and then called the signing function again.
I am unable to get this working that way. I had to convert my private key in the .pem file into XML in order to read it into the RSACryptoServiceProvider. If I try to concatenate the token secret onto the private key before converting, I get an error.
How do I go about signing the token secret so that I can do subsequent REST calls to Jira?